Html Asp.net Mvc重定向Url
在我的asp.net mvc项目中,我希望操作重定向到url,但我希望页面在新窗口中打开Html Asp.net Mvc重定向Url,html,asp.net-mvc,Html,Asp.net Mvc,在我的asp.net mvc项目中,我希望操作重定向到url,但我希望页面在新窗口中打开 public ActionResult Index(int id) { ... return Redirect(page.Url); } 您应该指定链接将使用视图中元素的target属性在新窗口中打开,即 <a href="@Url.Action("Index", "Controller", new{ area = "
public ActionResult Index(int id)
{
...
return Redirect(page.Url);
}
您应该指定链接将使用视图中元素的target属性在新窗口中打开,即
<a href="@Url.Action("Index", "Controller", new{ area = "", id = 1 })"
target= "_blank">Link text</a>
您应该指定链接将使用视图中元素的target属性在新窗口中打开,即
<a href="@Url.Action("Index", "Controller", new{ area = "", id = 1 })"
target= "_blank">Link text</a>
要在客户端打开一个新窗口,您必须在查看HTML或使用一些javascript中执行某些操作。这不能在控制器中完成
在视图中,您可以从调用此操作的位置设置操作链接的目标属性。要在客户端打开新窗口,您必须在视图HTML中或使用一些javascript。这不能在控制器中完成
在视图中,您可以从调用此操作的位置设置操作链接的目标属性。在服务器端,您可以在ajax调用后重新运行json
public ActionResult PreviewReport(Report rep)
{
return Json(new { type = "info", url = "..." }, JsonRequestBehavior.AllowGet);
}
在客户端执行javascript,结果来自对上述操作的ajax调用
function (result) {
if (result.type === 'info') {
window.open(result.url, '_blank');
}
}
在服务器端,您可以在ajax调用后重新运行json
public ActionResult PreviewReport(Report rep)
{
return Json(new { type = "info", url = "..." }, JsonRequestBehavior.AllowGet);
}
在客户端执行javascript,结果来自对上述操作的ajax调用
function (result) {
if (result.type === 'info') {
window.open(result.url, '_blank');
}
}
非常感谢。但在实际操作中,我做了一些控制,并决定打开空白目标或普通。据我所知,您不能从服务器端设置为在新窗口中打开。谢谢。但在实际操作中,我做了一些控制,并决定打开空白目标或普通。据我所知,您不能从服务器端设置为在新窗口中打开。