Quantcast
Channel: SharePoint 2010 - Development and Programming forum
Viewing all articles
Browse latest Browse all 11571

ASP Web Forms Error: Session state can only be used when enableSessionState is set to true

$
0
0

Hello,

I am developing a custom application page for a custom Web Forms I am creating, which I plan on using for custom task form into SharePoint 2010 Foundation.

Currently, I am trying to test it in Debug Mode using Visual Studio 2010 but when I am trying to use Sessions I get the error:

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 <configuration>\<system.web>\<httpModules> section in the application configuration


I've already done this on trying to fix:

On my page

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TestForm.aspx.cs" Inherits="TestForm" EnableSessionState="True" %>


And on my web.config

<pages enableSessionState="true">

..

<httpModules>
<remove name="Session" />
  <add name="Session" type="System.Web.SessionState.SessionStateModule, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</httpModules>

Note: I am getting an error when I try to add <module> into web.config

ASP .NET State Service is currently running.

And the part where it keeps error is when in PageLoad, I try to set a List object something like this:

List<object> myobject
    {
        get
        {
            if (Session["object"] == null)
            {
                Session["object"] = new List<object>();
            }
            return Session["object"] as List<object>;
        }
        set
        {
            Session["object"] = value;
        }
    }

..

protected void Page_Load(object sender, EventArgs e)
    {
        ..
        myobject= new List<object>();
        ..
    }


BUT the error still persists! I also try to restart IIS but still the error still happens.

I am running out of ideas so can you help me out?

Thank you!



Viewing all articles
Browse latest Browse all 11571

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>