Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/31.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# EndResponse为true response.Retry中的重定向_C#_Asp.net - Fatal编程技术网

C# EndResponse为true response.Retry中的重定向

C# EndResponse为true response.Retry中的重定向,c#,asp.net,C#,Asp.net,在try-catch块中使用response.redirect方法时,我不希望出现线程中止异常。我给出的结论是正确的。是否有任何可能的方法来代替抛出线程异常。该页面被重定向到登录页面 这是我的密码 try { Response.Redirect("login.aspx?fromLnkPg=1", true); } catch (Exception ex) { Response.Write(ex.Message.ToString()

在try-catch块中使用response.redirect方法时,我不希望出现线程中止异常。我给出的结论是正确的。是否有任何可能的方法来代替抛出线程异常。该页面被重定向到登录页面

这是我的密码

 try
    {
        Response.Redirect("login.aspx?fromLnkPg=1", true);
    }
    catch (Exception ex)
    {
        Response.Write(ex.Message.ToString());
    }
你可以

try
{
    Response.Redirect("login.aspx?fromLnkPg=1", true);
}
catch (Exception ex)
{
    // Removed as not needed due to redirect Response.Write(ex.Message.ToString());
    Response.Redirect("hompage.aspx");
}
您可能想使用

Response.IsClientConnected
所以

联系在一起

您需要在中传递
false
not
true

Response.Redirect("login.aspx?fromLnkPg=1", false);

Context.ApplicationInstance.CompleteRequest();
试试看

try
{
    Response.Redirect("login.aspx?fromLnkPg=1", true);
}
catch (ThreadAbortException) 
{
}
catch (Exception ex)
{
    Response.Redirect("home.aspx");        
}

我希望response.redirect方法中的end response属性为true。请提供任何可能的方式。可能重复的罚款。有没有可能的方法。。。我不想放置两个catch块。您想使用带有true的Redirect作为endResponse参数值,但不想有两个catch块?那么你要问的是不可能的-你需要使用false、two catch Block或forego Response。完全重定向以支持不同的重定向方式。谢谢,但如果我遇到任何其他异常。它应该重定向到home.aspx pageThank Response.isClient已连接;价值但是我的response.redirect应该为true。你想在任何异常情况下被重定向到主页吗?出于好奇,为什么你需要它为true?如果你传递true,线程将被中止,它将抛出异常。除了处理异常的开销之外,这似乎表明您希望在重定向发生后发生一些事情,这是错误的。做你需要做的,然后将请求传递到下一页。好问题,我使用fiddler调试器。它显示了html输出页面。页面重定向的位置。如果我对结束回答为真。fiddler调试器html头仅登录.aspx页面。。。进程也停止了。这是正确的功能。重定向就是这样做的,在服务器上重定向。没有理由编写代码以便使用fiddler,部署时fiddler不会在服务器上运行。你看错了,对不起。。我不知道还有别的办法
try
{
    Response.Redirect("login.aspx?fromLnkPg=1", true);
}
catch (ThreadAbortException) 
{
}
catch (Exception ex)
{
    Response.Redirect("home.aspx");        
}