Posted by craig
Sunday, April 26, 2009 1:29:34 PM
problem with Session state when inheriting a page and using Server.transfer
Error with Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive.
I had a hard time finding the solution to an invalid session problem. My case occurred when I inherited from a custom base page and used Server.Transfer I obtained this error.
An exception of type System.Web.HttpException occurred in System.Web.dll but was not handled in user code
Additional information: Session state can only be used when
enableSessionState is set to true, either in a configuration file or in
the Page directive. Please also make sure that
System.Web.SessionStateModule or a custom session state module is
included in the section in the application configuration.
The problem is that the Session is reset in Server.Transfer.  In my case I was using Server.Transfer to do URL mapping.  Fortunately, I found a much better solution and recommended to solution which is to use: HttpContext.Current.RewritePath();
Copyright 2009 AnyTime