0
我想重定向到使用Server.Transfer的另一页,我有这个简单的代码:Server.Transfer不起作用?
if (Page.IsPostBack)
{
try
{
Server.Transfer("AnotherPage.aspx");
}
catch (Exception)
{
throw ;
}
}
但我发现了一个错误:“对于AnotherPage.aspx执行错误子请求”。无法在网上找到解决方案。
只要提一下,Response.Redirect完美无瑕。
在浏览器中转到AnotherPage.aspx时会发生什么?它工作吗?它在同一个文件夹/路径中吗? – 2010-05-11 07:49:24
你实际上只是试图将用户重定向到新页面吗?如果是这样,请使用Response.Redirect()而不是Server.Transfer()。如果AnotherPage.aspx上存在错误,在使用Response.Redirect()*或*之后,它们会变得很清晰,直接从浏览器导航到AnotherPage.aspx。 – Richard 2010-05-11 07:51:11
当你移除try/catch块时会发生什么?在这里吃例外是没有意义的,然后问什么是错的。 – 2013-04-19 04:41:55