Server.Transfer does not run ASP.NET pipeline
Things I’ve learnt today: One.
What I’ve learnt: If you use the convenient (if old school) Server.Transfer method to render a different page to a client then you need to be aware that ASP.NET pipeline events1 will not run. You know – BeginRequest, AuthenticateRequest – unimportant things like that.
Basically – nothing that happens in Global.asax, HttpModules etc… will happen for this page.
This caused a rather embarrassing scenario for me.
If you requested a page which did not exist – then I Server.Transfer’ed you to a 404.aspx page.
At the time this seemed like good SOC – I can have a whole page which takes care of setting the correct HTTP status code, taking care of common misses etc. without issuing a redirect – which would mean you lost the url in your browser. (Something that asp.net does way to much for my tastes – but thats a whole ‘nother post).
Problem is that – the HttpModule I have which hooks up the correct “skin” for that customer based on the host header didn’t run – which meant that the user got the “default” skin – in this case another customers.
Anyway – it’s all fixed now – but I’ve had to duplicate the code to hook up the correct skin in two places. Which is not so hot.
ASP.NET is so cool. I want to have it’s children. NOT. Seriously – who wrote this – what were they thinking?
Oh – we have a special case – well – we’ll re-implement some aspects of the whole fricking pipeline again to take care of this!
ARRRGGG!!!!
- http://msdn2.microsoft.com/en-us/library/ms178473.aspx [↩]
No Comments Yet