url.Action在ASP.NET MVC页面上的新窗口中打开链接 [英] url.Action open link in new window on ASP.NET MVC Page

查看:108
本文介绍了url.Action在ASP.NET MVC页面上的新窗口中打开链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用url.Action打开一个新窗口. 并且新的Window网址不在当前项目(外部网站)中.

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. 我需要在新窗口中打开它.
  2. 它将转到http://localhost:57391/Home/http:/www.yahoo.com,而不是直接发送到Yahoo.
  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.

这是我的代码:

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

推荐答案

您根本不需要使用辅助方法:

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仅适用于控制器操作,而外部链接则不适用.使用纯HTML进行链接没有错.

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

这篇关于url.Action在ASP.NET MVC页面上的新窗口中打开链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆