Asp.net mvc 3 如何在运行结果中打开浏览器?
我有一个action tresult方法,其中我想在新窗口或新选项卡中打开一个url。我如何处理它 在我的代码中,它不起作用,我的意思是将它重定向到成员帐户,并且不打开我的urlAsp.net mvc 3 如何在运行结果中打开浏览器?,asp.net-mvc-3,Asp.net Mvc 3,我有一个action tresult方法,其中我想在新窗口或新选项卡中打开一个url。我如何处理它 在我的代码中,它不起作用,我的意思是将它重定向到成员帐户,并且不打开我的url public ActionResult myactionresult() { Response.Write("<script language=\"javascript\">"); Response.Write("window.open('" + "http://
public ActionResult myactionresult()
{
Response.Write("<script language=\"javascript\">");
Response.Write("window.open('" + "http://www.xxx.com" + ,'_blank')");
Response.Write("</script>");
return RedirectToAction("Index", "MembersAccount");
}
public ActionResult myactionresult()
{
回答。写(“”);
Response.Write(“window.open”(“+”)http://www.xxx.com“+,”空白“)”;
回答。写(“”);
返回重定向到操作(“索引”、“成员计数”);
}
试试这个:
控制器
public ActionResult myactionresult()
{
String jScript = String.Empty;
jScript = "<script language=\"javascript\">";
jScript += "window.open('http://www.xxx.com' ,'_blank')";
jScript += "</script>";
ViewBag.jScript = jScript;
return RedirectToAction("Index", "MembersAccount");
}
这将解决您的问题;我的重定向必须发生在实际操作中。结果在您的情况下,任何重定向都将发生happened@motevallizadeh,你想通过actionresult打开另一个窗口,而不想打开相应的操作吗?@Kundan Singh Chouhan,是的,我想在它之后打开它这最后一行重定向到我的action@motevallizadeh是吗你运行这段代码吗?我想这是正常的。
@ViewBag.jScript