如何在动作结果中打开浏览器?

时间:2012-10-27 16:55:14

标签: asp.net-mvc-3

我有一个动作tresult方法,在其中我想在新窗口或新标签中打开一个网址,我该如何处理它呢?

在我的代码中,它不起作用,我的意思是将其重定向到成员帐户,不要打开我的URL

public ActionResult myactionresult()
    {
         Response.Write("<script language=\"javascript\">");
         Response.Write("window.open('" + "http://www.xxx.com" + ,'_blank')");
         Response.Write("</script>");

       return RedirectToAction("Index", "MembersAccount");
      }

1 个答案:

答案 0 :(得分:0)

请改为尝试:

控制器

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");
}

查看: 查看正文中的任何内容

@ViewBag.jScript

这将解决您的问题;

相关问题