Situation:
- In Web.Config we have CustomErrors turned on with
redirectMode="ResponseRewrite". - In
Page_Loadof our MasterPage we access theSessionproperty of thePage.
Problem:
When an Error occurs on any page the user gets redirected (via Rewrite) to our Error.aspx Page. There in the Page_Load of the MasterPage we access the Session and get an HttpException telling us to enable SessionState. But we have the SessionState enabled, definitly.
Question:
How can we access the session after a UrlRewrite in the Page_Load Event of our MasterPage?
The solution we ended up with:
We can do this because the data we get from the Session is not Essential for us on the ErrorPage.
Also note that accessing
HttpContext.Current.Sessionwill not throw anHttpExceptionwhereas accessingPage.Sessionwould.