Hi Abishek,
Sorry for the delay in getting back to you. I tested the above issue with the code given by you, but I was unable to reproduce the issue. It may be caused if you use the Response.End, Response.Redirect, or Server.Transfer method, a ThreadAbortException exception can occurs. Try to use a try-catch statement to catch this exception. The Response.End method ends the page execution and shifts the execution to the Application_EndRequest event in the application''s event pipeline. The line of code that follows Response.End is not executed that’s why this exception is thrown.
To work around this problem, use one of the following methods:
- For Response.End, call the HttpContext.Current.ApplicationInstance.CompleteRequest method instead of Response.End to bypass the code execution to the Application_EndRequest event.
- For Response.Redirect, use an overload, Response.Redirect(String url, bool endResponse) that passes false for the endResponse parameter to suppress the internal call to Response.End. For example:
Response.Redirect ("nextpage.aspx", false);
If you use this workaround, the code that follows Response.Redirect is executed.
- For Server.Transfer, use the Server.Execute method instead.
I hope this would solve the issue. Please try this and let me know if you have any further questions.
Also here is the test sample that I used:
Sample.
Thanks,
Ajish.