I am trying open a new window using url.Action. And the new Window url is out of this current project(external website).
我正在尝试使用url.Action打开一个新窗口。新的窗口网址不在当前项目(外部网站)之内。
Here are two things i need to do:
以下是我需要做的两件事:
- I need to open it in a new window.
- It is going to
http://localhost:57391/Home/http:/www.yahoo.com
instead of directly to Yahoo.
我需要在新窗口中打开它。
它将转到http:// localhost:57391 / Home / http:/www.yahoo.com而不是直接转到Yahoo。
Here is my code:
这是我的代码:
<tr >
<td>
<a href="<%= Url.Action("http://www.yahoo.com") %>"><span>Go to Yahoo</span></a>
</td>
</tr>
3 个解决方案
#1
14
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.
Html.Action仅适用于控制器操作,外部链接不适用。使用纯HTML链接没有任何问题。
#2
1
You can try doing something like this
你可以尝试做这样的事情
<a href="http://@Model.Link" target="_blank"><span>@Model.Link</span></a>
#3
-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>
#1
14
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.
Html.Action仅适用于控制器操作,外部链接不适用。使用纯HTML链接没有任何问题。
#2
1
You can try doing something like this
你可以尝试做这样的事情
<a href="http://@Model.Link" target="_blank"><span>@Model.Link</span></a>
#3
-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>