I'm trying to get a Session["user"]
on Page_Load
but it keep giving me this crash:
'Session' threw an exception of type system.web.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 \\ section in the application configuration.
Here is my web.config
<configuration>
<system.web>
<pages enableSessionState="true" />
<httpModules>
<add name="Session" type="System.Web.SessionState.SessionStateModule" />
</httpModules>
</system.web>
</configuration>
There are other things inside the configuration tag, but the important part is this one, where the config is correct, but the error still the same.
Why is this happening?
No big deal in the .aspx
protected void Page_Load(object sender, EventArgs e)
{
try
{
if (Session["user"] == null)
Response.Redirect("~/Login.aspx");
}
}