Search code examples
asp.netjqueryasp.net-mvc-2window.open

Post and open in new window in Asp.Net MVC 2?


How can I post a form to an HttPost Action method and open the returned View in a new window?

I've tried to find some way to do it using the window.open function and jQuery, but I can't find anything that works... It seems there should be an easy way to do this in MVC? Everything works fine returning a normal view from the post method, so all I need is to open that returned view in a new window instead (the posting page can simply stay as it is).

Any ideas?


Solution

  • <form method="post" action="yourcontroller" target="_blank">
     ...
    </form>
    

    Although specifying target="_blank" to open a new window is annoying to many users and makes your site less accessible, so use this only when you have a really good reason.