I am facing the problem that I need multiple ASPState databases for different ASP.NET projects on the same db server, beacuse I really want to share the Session State db for those projects.
After doing some research (e.g. here and here), I created the first database using following command:
aspnet_regsql.exe -E -S "fooserver" -ssadd -sstype "c" -d "FooProject.Sessions"
In the <system.web>
section of my web.config, I have following entry:
<sessionState mode="SQLServer" allowCustomSqlDatabase="true" sqlConnectionString="data source=fooserver;integrated security=True;database=FooProject.Sessions" cookieless="false" timeout="60" />
But when I try to Access the Session
property of my controller context, I get an NullReferenceException (Session is null).
When I set the allowCustomSqlDatabase
attribute of the configuration entry to false
, everything works fine.
What did I do wrong? It seems like no one else has this problem Thank you in advance!
PS: Just tell me if I need to provide more information.