I am trying to use the Application_Error to redirect the user to a custom error page. I know I could use the web.config to do this, but let's assume for now that this is not a desirable path to take.
Initially, I tried to do a Response.Redirect to perform this, however, there seem to be occasions where the current http context does not define the response object. So, I attempted to perform a check to make sure that the response object is not null prior to attempting the redirection, and if it is not defined, perform a Server.Transfer instead.
What happens is that in most cases, the Redirect causes the browser to some generic "friendlyish" error page rather than the requested error page.
So then I tried using Server.Transfer exclusively, and this worked well for most cases, however, sometimes the transfer didn't seem to take in the browser. Changing it back to a redirect in these cases solved that problem, but reintroduced the issue where the errors previously being captured and transferred now were being redirected.
What I surmised from this is that in certain contexts where the Application_Error method is trapped, it is necessary to use Server.Transfer in redirection, whereas in others, it is necessary to use Response.Redirect. The question then became twofold: (a) When is one necessary and when is the ot
View Complete Post