ASP.Net MVC 3 Controller Action and Open New Window

action, asp.net, asp.net-mvc-3, controller

Solution

Technically, this can be done by returning javascript that will open the new window.

However, most browsers will kill a new window called in this manner (i.e. popup blocker).

You would be better off, if possible, by opening the link to your action in a new window from the start;

@Html.ActionLink("New report", "New", "Report", null, new {target = "_blank"})

Edit

I can see from your action, that it is probably a form that creates the report; you can also use the attribute `target='_blank'` on a form as well.

Problem

i have a controller and an action. this action is to save data into database. and now, i want when i submit a button, my controller do an action and open new window. ``` public ActionResult New(FormCollection collection) { data.Population_Code = collection["Countrys[0].CountryCode"]; data.Population_Desc = collection["Countrys[0].CountryDesc"]; data.Population_Grouping = collection["Countrys[0].CountryGroup"]; data.Population_Type = "CNTRY"; data.Population_Redudant = "N"; data.Population_Modified_At = officeCode.User_Office.ToString(); db.SaveChanges(); //example for new window //window.open('/Report/New.aspx') return RedirectToAction("index"); } ``` so my controller do an action and open a new window. anyone can help me ? thanks

Original source