Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

url.Action open link in new window on ASP.NET MVC Page

Tags:

asp.net-mvc

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

Here are two things i need to do:

  1. I need to open it in a new window.
  2. It is going to http://localhost:57391/Home/http:/www.yahoo.com instead of directly to Yahoo.

Here is my code:

<tr >
       <td>                    
        <a href="<%= Url.Action("http://www.yahoo.com") %>"><span>Go to Yahoo</span></a> 
         </td>
    </tr>
like image 958
Rita Avatar asked Mar 04 '10 19:03

Rita


2 Answers

You don't need to use the helper methods at all:

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

Html.Action is only for controller actions, which an external link is not. There's nothing wrong with using plain HTML to link with.

like image 151
Richard Szalay Avatar answered Sep 29 '22 02:09

Richard Szalay


You can try doing something like this

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

like image 29
Santan Pereira Avatar answered Sep 29 '22 02:09

Santan Pereira