tags:

views:

48

answers:

1

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?

+4  A: 

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" });
Ryan Brunner
Even though this would work, it makes all of your pages and views non XHTML valid. A solution with using the attribute rel with a value external, like this rel="external" and then hooking up JS to open the links decorated that way in a new window, is better.
mare
Very true if you're targeting XHTML. If you're targeting HTML 4.01 / HTML 5, however, target is perfectly acceptable.
Ryan Brunner