Url.Action open the link in a new window on the ASP.NET MVC page

I am trying to open a new window using url.Action. And the new window url is coming out of this current project (external website).

Here are two things I need to do:

  • I need to open it in a new window.
  • It will be http://localhost:57391/Home/http:/www.yahoo.cominstead of direct access to Yahoo.

Here is my code:

<tr >
       <td>                    
        <a href="<%= Url.Action("http://www.yahoo.com") %>"><span>Go to Yahoo</span></a> 
         </td>
    </tr>
+5
source share
3 answers

You do not need to use helper methods at all:

<a href="http://www.yahoo.com" target="_blank"><span>Go to Yahoo</span></a>

Html.ActionIt is intended only for controller actions that the external link does not have. There is nothing wrong with using simple HTML for communication.

+14
source

You can try to do something like this

<a href="http://@Model.Link" target="_blank"><span>@Model.Link</span></a>

+1
source

If the website parameter is a dynamic -or-attachment from Model, we can try something like this.

<a href="@Model.Website" target="_blank">@Model.Website</a>
-1
source

All Articles