6

我们正在使用 ASP.NET Webforms(不是 MVC)。

我的问题是:是否可以使用回发打开一个新的浏览器窗口,然后使用各种 Response.Redirect?

4

3 回答 3

7

我没有遇到过 Response.Redirect 可以导航打开新窗口的情况。

这是一种不使用 Response.Redirect 的方法,您可以尝试:

ScriptManager.RegisterStartupScript(this, typeof(string), "New_Window", "window.open( 'http://www.website.com', null, 'height=800,width=1280,status=yes,toolbar=yes,menubar=yes,location=no' );", true);
于 2013-08-07T04:51:49.217 回答
1

简短的回答?不。

长答案:

ASP.NET 是服务器端框架,而浏览器窗口的概念是客户端框架。Response.Redirect只是最终将Location: [whatever the new url is]标头作为输出流的一部分发送。碰巧的是,几乎所有浏览器都通过加载该标头中的 url 来处理该标头。

如JLC007 的回答中所述,最轻松的方法是在回发中使用 javascript 打开新窗口。另一种可能的选择是在呈现的表单上使用目标属性。

于 2013-08-07T04:48:03.690 回答
1

尝试这个

 ScriptManager.RegisterStartupScript(this, typeof(string), "openWindow", 
     "window.open( 'http://www.website.com', target="_blank", 
     'height=800,width=1280,status=yes,toolbar=yes,menubar=yes,location=no' );",
       true);
于 2013-08-07T05:46:25.223 回答