6

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>
Mathieu
  • 4,449
  • 7
  • 41
  • 60
Rita
  • 1,237
  • 5
  • 24
  • 46

3 Answers3

16

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.

Richard Szalay
  • 83,269
  • 19
  • 178
  • 237
2

You can try doing something like this

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

Santan Pereira
  • 75
  • 3
  • 12
-1

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

<a href="@Model.Website" target="_blank">@Model.Website</a>
Raaghav
  • 3,000
  • 1
  • 23
  • 21