My ASP.NET web application works fine in Internet Explorer, but in Firefox and Chrome I have a problem where HttpContext.Current is defined, but HttpContext.Current.Session is null. The error is probably caused by the fact that the Session object is being accessed to early in the ASP.NET page life cycle. But since the web site is primarely going to be accessed using Internet Explorer I’m hoping to find a quick, acceptable fix. Perhaps something along these lines:
if (HttpContext.Current.Session == null)
{
// Create Session - but how?
}
So the question is: Can I create the Session object programmatically in ASP.NET?
Edit: The bug was apparantly related to a .designer file that was out of sync. Weird, but now it works.
I think the problem that you actually have is that IE is the only browser accepting the Session cookie that ASP.NET uses to persist the session identifier.
Either ensure that all your browsers are accepting cookies or set up your ASP.NET application to use cookieless sessions.
The answer to your question however is no, you cannot create the session yourself. ASP.NET must do this on your behalf.