Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Dec 24, 2012 02:25 PM by ignatandrei
Contributor
2777 Points
1161 Posts
Dec 24, 2012 02:16 PM|LINK
I have a:
private static HttpSessionStateBase TheSession;
in my AccountController class.
static AccountController() { TheSession = HttpContext.Current.Session; }
But I'm getting a compile time errror saying:
An object reference is required for the non-static field, method, or property System.Web.Mvc.Controller.HttpContext.get'
And the HttpContext object is indicated as the cause of this error.
Any suggestion for getting around this issue?
All-Star
134521 Points
21576 Posts
Moderator
MVP
Dec 24, 2012 02:25 PM|LINK
TheSession = System.Web.HttpContext.Current.Session;
eric2820
Contributor
2777 Points
1161 Posts
Static Constructor needs to HttpContext...
Dec 24, 2012 02:16 PM|LINK
I have a:
private static HttpSessionStateBase TheSession;
in my AccountController class.
static AccountController()
{
TheSession = HttpContext.Current.Session;
}
But I'm getting a compile time errror saying:
An object reference is required for the non-static field, method, or property System.Web.Mvc.Controller.HttpContext.get'
And the HttpContext object is indicated as the cause of this error.
Any suggestion for getting around this issue?
http://www.my-msi.net/Admin
blog
If a post helps you, please mark it as Ansered, thank-you.
ignatandrei
All-Star
134521 Points
21576 Posts
Moderator
MVP
Re: Static Constructor needs to HttpContext...
Dec 24, 2012 02:25 PM|LINK
TheSession = System.Web.HttpContext.Current.Session;