Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

calling Response.End() after Response.Redirect()

Tags:

asp.net

Is it necessary to call Response.End() after Response.Redirect(url)

Update

Thanks for all the answers. Because some answers say that it's necessary and others say no, I have searched more and have found in msdn under remarks the following:

Redirect calls End which raises a ThreadAbortException exception upon completion.

like image 660
HCL Avatar asked Jan 13 '11 16:01

HCL


2 Answers

Response.Redirect calls Response.End for you

I don't agree its good practice - it leads to misleading code.

MSDN:

Redirect calls End which raises a ThreadAbortException exception upon completion.

The laws of HTTP explain that once a response is sent the server is done (no more code gets called)

like image 110
m.edmondson Avatar answered Sep 30 '22 05:09

m.edmondson


Response.Redirect allows you to call Response.End.

Response.Redirect(url, true);
like image 26
Jack Marchetti Avatar answered Sep 30 '22 06:09

Jack Marchetti