c# - Session.Abandon Not Firing or Throwing error message -
i have following piece of code throwing error message need enable session on web.config, none of things have found far, can tell me how suppose working?.
i have tried place code within decline on page_load server seems avoid session's instructions:
public partial class decline : datapage { protected decline() { session.removeall(); session.clear(); session.abandon(); response.cookies.remove("accessed"); } protected void page_load(object sender, eventargs e) { response.redirect("~/account/login.aspx"); } }
this full message:
session state can used when enablesessionstate set true, either in configuration file or in page directive. please make sure system.web.sessionstatemodule or custom session state module included in
<configuration>\<system.web>\<httpmodules>
section in application configuration
this running .net 4 framework , configurations coming following answer not quite fit current project. since providing .net mvc 2 solution. helpful there equivalent on .net 4
<system.webserver> <modules runallmanagedmodulesforallrequests="true"> <remove name="session" /> <add name="session" type="system.web.sessionstate.sessionstatemodule, system.web, version=2.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a" /> </modules> </system.webserver>
session state can used when enablesessionstate set true either in configuration
also provided page following line
<%@ page title="" language="c#" codefile="decline.aspx.cs" inherits="decline" enablesessionstate="true" %>
which not make difference @ if there or not. running on iis 7.5
i had same problem , did in web.config add
<system.webserver> <modules runallmanagedmodulesforallrequests="true"/> </system.webserver>
and in page using
enablesessionstate="true"
and can try remove 1 session , check if has been remove
session.remove("test"); if (session["test"] == null) { //woooo work ; } else { // ???? }
Comments
Post a Comment