asp.net - Server.TransferRequest for IIS 6 -



asp.net - Server.TransferRequest for IIS 6 -

is there way false behavior of transferrequest in iis 6? ability re-process whole pipeline without client having create new request?

i'm trying handle 404 error application_error, magic see if url changed (in case utilize response.redirect redirect new url) if there 404 want serve pretty looking 404 page has deal showing content part of users session.

the problem if utilize server.transfer, request context null @ point 404 page crashes. don't want utilize request.redirect because want browser url still on missing url 404 status code gets interpreted missing resource.

on iis 7 can utilize transferrequest want. browser retains missing url , session context available 404 page code. there way similar iis 6? (transferrequest available in iis 7 in pipeline mode , our production servers still on iis 6)

one possible solution create redirect flag, , create rewritepath on beginrequest.

for example, place code on global.asax

protected void application_beginrequest(object sender, eventargs e) { if (httpcontext.current.request.rawurl.endswith("error")) { httpcontext.current.rewritepath("404coolpage.aspx", false); } // .... rest code }

and create redirect on

void application_error(object sender, eventargs e) { //... code if(system.web.httpcontext.current.request.querystring.count > 0) response.redirect(httpcontext.current.request.rawurl + "&error"); else response.redirect(httpcontext.current.request.rawurl + "?error"); }

this way, create redirect, , maintain url is.

my error setup

by way, utilize the server.transfer , working me. error setup , transfer done using server, not sure page have problem request context

void application_error(object sender, eventargs e) { // ... log errors ... string cthefile = httpcontext.current.request.path; // in case error within 404coolerror.aspx // check not calling self , dead loop. if(!cthefile.endswith("404coolerror.aspx")) server.transfer("~/404coolerror.aspx"); }

and on web.config

<customerrors redirectmode="responserewrite" ... />

asp.net iis-7 error-handling iis-6 http-status-code-404

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -