I want to know the default value of endResponse parameter of HttpResponse.Redirect Method (String, Boolean)
method
Asked
Active
Viewed 4,862 times
6

Andrey Korneyev
- 26,353
- 15
- 70
- 71

Imran Rafique
- 329
- 3
- 10
1 Answers
9
The default value of endResponse
parameter of HttpResponse.Redirect is true
.
Calling Redirect is equivalent to calling Redirect with the second parameter set to true.
Redirect calls End which throws a ThreadAbortException
exception upon completion. This exception has a detrimental effect on Web application performance. Therefore, it is recommended that instead of this overload you use the HttpResponse.Redirect(String, Boolean)
overload and pass false
for the endResponse
parameter, and then call the CompleteRequest
method. For more information, see the End
method.
See this MSDN link for reference - https://msdn.microsoft.com/en-us/library/t9dwyts4%28v=vs.110%29.aspx

Manik Arora
- 4,702
- 1
- 25
- 48
-
Appreciate this is an old reply @ManikArora but does this apply for redirecting in an Asp.Net Application_Error handler too? Would you want `endResponse` set to false there too? – Gavin Sutherland Feb 27 '20 at 16:41
-
1@GavinSutherland, I have not personally used Redirect false, in Application_Error, if you have some operations which you'd like to execute even after the response is redirected then I think it should work for that kind of use case - have a look at this SO answer, he has explained very nicely - https://stackoverflow.com/a/12957854/3748701 – Manik Arora Mar 02 '20 at 09:13