I lost several hours on a problem that what solved by something very simple but unexplainable from my side. I had to create a new MasterPage for our MySites. On the root site collection of the MySites WebApplication we published some custom application pages to extend the standard functionality. These pages used the session state (HTTPContext.Current.Session) to store their model. Everything worked fine with the old MasterPage, but as soon as I selected the new one, the Edit Profile page started complaining that the SessionState was empty. I checked lots of things, even copied the old MasterPage sourcecode into the new MasterPage which didn’t worked neither. After lots of google links, a lot of frustration, even opening IIS, web.config files, trust configs, etc I found the solution on an other blog (lucky for me I’m not alone). Because it took me quite some links to read, I repost the solution here.

- If you get a HttpContext.Current.Session is nothing or HttpContext.Current.Session is null.
- If a page gives you “Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive” and you’re absolutely sure you did this and other things Microsoft recommends to use Session State in SharePoint.
- If you have enabled Session State through SharePoint Central Administration.
- When you try to set the EnableSessionState attribute on the Page directive of your Application Page and the following error comes back: “The enablesessionstate attribute on the page directive is not allowed in this page.”.

Then just use the ‘Reset to site definition‘ in your Site Settings of your Site Collection. Simple isn’t? What is it doing, well send an email to Microsoft, because I can’t tell you, but it fixed the problem for me.

Advertisement