I don't want the thread abort exception when i use response.redirect method inside try catch block . I give end response is true. Is there any possible way instead of throws thread exception. The page is redirected the login page.
This is my code,
try
{
Response.Redirect("login.aspx?fromLnkPg=1", true);
}
catch (Exception ex)
{
Response.Write(ex.Message.ToString());
}
As linked here
you need to pass false
not true
in
Response.Redirect("login.aspx?fromLnkPg=1", false);
followed by
Context.ApplicationInstance.CompleteRequest();
You could do
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");
}
You may want to use
Response.IsClientConnected
So
bool b = Response.IsClientConnected;
Response.Redirect("login.aspx?fromLnkPg=1", b);
try follwing
try
{
Response.Redirect("login.aspx?fromLnkPg=1", true);
}
catch (ThreadAbortException)
{
}
catch (Exception ex)
{
Response.Redirect("home.aspx");
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.