dur*_*uru 3 c# asp.net-mvc asp.net-mvc-5
这是我的代码
public ActionResult Contact()
{
//var getRequest = (HttpWebRequest)WebRequest.Create("https://brisol.net/av-d");
//var getResponse = (HttpWebResponse)getRequest.GetResponse();
//return new HttpWebResponseResult(getResponse);
return ExternalGet("https://sample.net/av-d");
}
/// <summary>
/// Makes a GET request to a URL and returns the relayed result.
/// </summary>
private HttpWebResponseResult ExternalGet(string url)
{
var getRequest = (HttpWebRequest)WebRequest.Create(url);
var getResponse = (HttpWebResponse)getRequest.GetResponse();
return new HttpWebResponseResult(getResponse);
}
Run Code Online (Sandbox Code Playgroud)
在上面的代码中,当我单击联系链接时,它会在同一窗口中打开以下网址,但我想从 mvc 控制器打开新窗口。
您可以将目标用于空白页
HTML 代码
<input type="button" target="_blank"/>
Run Code Online (Sandbox Code Playgroud)
MVC代码
@Html.ActionLink(" ", "ActionName", "ControllerName", null, new { target = "_blank", @class = "btn btn-primary fa fa-list"})
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
40555 次 |
| 最近记录: |