OVH Cloud OVH Cloud

exception response.redirect()

1 réponse
Avatar
Jonny
Hello tlm,

Pouruqoi une exception est levee lors d'un
response.redirect() ? mon application fonctionne quand
meme.

Merci

1 réponse

Avatar
Norm
> Pouruqoi une exception est levee lors d'un
response.redirect() ? mon application fonctionne quand
meme.



Suite à 3 mots inscrits dans google : Response redirect exception :

http://support.microsoft.com/kb/312629/EN-US/

Response.Redirect(): when u use this method the IIS server does not redirect
the user to requested page infact IIS sends the following HTTP header to the
browser.:
HTTP 1.0 302 Object Move
Location URL

making the browser automatically request a new page. Since the redirection
goes through a round-trip to the browser, it generates an additional request
and increased bandwidth usage. Another point to remember here for classic
ASP programmers is that buffering is turned on by default in IIS5 so if
there is any output thrown before redirect statement will not cause any
exception like in ASP, the exception message as seen below.

System.Web.HttpException: Cannot redirect after HTTP headers
have been sent.

Also Response.Buffer is outdated instead use Response.BufferOutput for any
buffering activity.

Limitations:

1.. It forcing you to cancel all output from the first page
2.. You also lose the contents of the Request collection.
3.. Transactions of both pages gets isolated