I encountered something I wasn’t expecting today, not that unusual occurrence in coding, I know.
I was happily deploying a site, throwing all my files onto my hosting provider, when I had the radical idea of testing my deployment. Crazy! And what should I encounter was this error:
Request is not available in this context
Hmm, that was a new one. It was firing from the Global.asax file, specifically, the Application_Start event. Nothing there but some variable initializations, you know, the standard stuff.
But no more initializations in the Application_Start anymore I discovered when I went searching for a resolution to my problem. I found a post which provided the details of why I was getting that crafty message. Even the title of the post was right on: IIS7 Integrated mode: Request is not available in this context exception in Application_Start.
So I moved my initializations outside of the Global.asax file and put them elsewhere. Not that hard a fix, just nothing I had seen before.