I have a class which inherits from the System.Web.UI.Page class, like mysystem.
When I try to create an instance of mysystem in a winform appplication it throws an HttpException:
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
<configuration>\<system.web>\<httpModules>
section in the application
configuration.
I then googled this problem and try to enable the session state, but all are not affected.
So, can anybody tell me how to solve this case?
Any class that inherits from
System.Web.UI.Pagewill attempt to utilise parts of the asp.net runtime when it’s instantiated, so when it’s used in a winforms application, it just won’t work.If there are methods that you need inside this class from another DLL, I’d suggest refactoring them into a separate class as: