Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How would I open an MVC View in a new browser window

Tags:

asp.net-mvc

I have an ASP.Net MVC application. I would like to create a view that lists the contents of a simple collection and show it in a new browser window.

Is there a way to show a view in a new browser window using a simple link?

I have struck out with Html.ActionLink. The Url.Action below does result in the Controller action being called but does not open in a new browser window.

Open MVC View in New Browser.

Is opening a view in a new browser window possible in MVC?

If so, does anyone know how?

like image 541
Doug Kimzey Avatar asked Dec 28 '22 08:12

Doug Kimzey


1 Answers

You can specify target=_blank in the HTML properties of your link to open it in a new window. There's a parameter on Html.ActionLink that allows you to specify arbitrary HTML properties to add to your link, like so:

Html.ActionLink("Text", "Action", new { id = 1 }, new { target = "_blank" });
like image 117
Ryan Brunner Avatar answered Feb 12 '23 08:02

Ryan Brunner