locked
Good news for those of you who get "Unable to make the session state request to the session state server." error.. RRS feed

  • Question

  • User-990865973 posted

    Dear all,

    Due to the known problem of session variables getting lost if using InProc-server during frequent changes in development, I had to choose between SQL and ASP.NET State server, so I opted for the second. Initially, all fine, but after using it for a few days, I started to get this error:

     Server Error in '/cv2' Application.
    Unable to make the session state request to the session state server. Please ensure that the ASP.NET State service is started and that the client and server ports are the same.  If the server is on a remote machine, please ensure that it accepts remote requests by checking the value of HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\aspnet_state\Parameters\AllowRemoteConnection.  If the server is on the local machine, and if the before mentioned registry value does not exist or is set to 0, then the state server connection string must use either 'localhost' or '127.0.0.1' as the server name.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Web.HttpException: Unable to make the session state request to the session state server. Please ensure that the ASP.NET State service is started and that the client and server ports are the same.  If the server is on a remote machine, please ensure that it accepts remote requests by checking the value of HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\aspnet_state\Parameters\AllowRemoteConnection.  If the server is on the local machine, and if the before mentioned registry value does not exist or is set to 0, then the state server connection string must use either 'localhost' or '127.0.0.1' as the server name.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:

    [HttpException (0x80004005): Unable to make the session state request to the session state server. Please ensure that the ASP.NET State service is started and that the client and server ports are the same.  If the server is on a remote machine, please ensure that it accepts remote requests by checking the value of HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\aspnet_state\Parameters\AllowRemoteConnection.  If the server is on the local machine, and if the before mentioned registry value does not exist or is set to 0, then the state server connection string must use either 'localhost' or '127.0.0.1' as the server name.]
       System.Web.SessionState.OutOfProcSessionStateStore.MakeRequest(StateProtocolVerb verb, String id, StateProtocolExclusive exclusiveAccess, Int32 extraFlags, Int32 timeout, Int32 lockCookie, Byte[] buf, Int32 cb, Int32 networkTimeout, SessionNDMakeRequestResults& results) +1565
       System.Web.SessionState.OutOfProcSessionStateStore.SetAndReleaseItemExclusive(HttpContext context, String id, SessionStateStoreData item, Object lockId, Boolean newItem) +192
       System.Web.SessionState.SessionStateModule.OnReleaseState(Object source, EventArgs eventArgs) +355
       System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +92
       System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64


    Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42

     Meanwhile the event log on the server (W2K2003) always logged this error (rI've emoved some details from it):

     Event code: 3009
    Event message: Unable to make the session state request to the session state server. Details: last phase='Reading response from the state server', error code=0x8007274C, size of outgoing data=45999
    Event time: 9/29/2006 11:40:17 AM
    Event time (UTC): 9/29/2006 3:40:17 AM
    Event ID: 0ec55d45b61f457d95d3d3c256d7cab7
    Event sequence: 4
    Event occurrence: 1
    Event detail code: 50016
     
    Application information:
        Application domain: /LM/W3SVC/1/Root/cv2-4-128039748000937500
        Trust level: Full
        Application Virtual Path: **********
        Application Path: **********
        Machine name: ********** 
     
    Process information:
        Process ID: 720
        Process name: w3wp.exe
        Account name: NT AUTHORITY\NETWORK SERVICE
     
    Exception information:
        Exception type: HttpException
        Exception message: Unable to make the session state request to the session state server. Please ensure that the ASP.NET State service is started and that the client and server ports are the same.  If the server is on a remote machine, please ensure that it accepts remote requests by checking the value of HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\aspnet_state\Parameters\AllowRemoteConnection.  If the server is on the local machine, and if the before mentioned registry value does not exist or is set to 0, then the state server connection string must use either 'localhost' or '127.0.0.1' as the server name.
     
    Request information:
        Request URL: **********
        Request path: **********
        User host address: 192.168.0.181
        User: ********** 
        Is authenticated: True
        Authentication Type: Forms 
     
    Thread information:
        Thread ID: 1 
        Is impersonating: False
        Stack trace:
     
     
    Custom event details:

    For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.

    "Of course" the link http://go.microsoft.com/fwlink/events.asp did not help, "we're sorry" page showed up.

    I also saw a lot of abandoned posts asking about lost session state on this forum when searching. Some suggested increasing the time out, which I believe had nothing to do with the issue.

    The state service configuration worked fine when running on the development machine, and I was 100% sure the asp.net state service had the correct and same port numbers.

    I also tried the latest VS 2005 SP1 beta on dev. machine and server but no effect on the issue (although it solved some other bugs).

    I also tried setting the ASP.NET state server registry key to accept remote connections (flag to 1 instead of 0), but no effect.

    It turned out this KB solved the issue:

    http://support.microsoft.com/kb/919080/en-us?spid=8940&sid=global

     Interestingly enough, I have not uninstalled the .NET 1.1 framework, and the server is a plain 32-bit platform, so the title was pretty misleading.

    So I "adapted" the hotfix to:

    1. change dir to: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727
    2. type aspnet_regiis -i -enable|
    3. Machine chews command for about 1 minute or so
    4. Done! When I click "log in" button on the start page with correct credentials, the session state is working fine again.

    And actually, that's all!

    Apparently, the ASP.NET 2.0 framework with IIS was corrupted, but I can't recall any particular action that specifically broke it, except that I did a system restart, which may have triggered some pending action initiated long ago.

    Would be interesting to know if this solves the problem for others who have the same issue.

     

     

     

     

    Friday, September 29, 2006 12:14 AM

All replies

  • User1392493338 posted

    Awesome, Dude.

    Thanks for the fix. 

    james 

     quoted:

    So I "adapted" the hotfix to:

    1. change dir to: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727
    2. type aspnet_regiis -i -enable|
    3. Machine chews command for about 1 minute or so
    4. Done! When I click "log in" button on the start page with correct credentials, the session state is working fine again.

     

     

     

    Thursday, January 3, 2008 8:35 AM
  • User-1656602346 posted

    Hi,

    I wanted to use the StateServer for storing sessions in a web farm scenario. To start with, I tried initally on one server where I ran the client and host on the same machine and I added the following code in web.config:

    <sessionState mode="StateServer" stateConnectionString="tcpip=localhost:42424"

    cookieless="false"/>

    But i kept getting the error mentioned above. Then I tried the solution mentioned, but I still keep getting the same error.

    Can anyone please let me know  what is it that I am doing wrong and what should I do?

    Thanks

    Friday, February 1, 2008 8:29 AM
  • User-2084896922 posted

    Hello,

    I just moved my web sites to a new local Windows Small Business Server 2003 and got the same error when I tried connecting to a site with a login screen, after logging in. (The site was built with Visual Studio 2005, using ASP.NET 2.0.50727.)
    I tried the solution in this article and got a different error when I refreshed the web page (Validation of viewstate MAC failed...). So I closed the browser window (on a client in the same LAN) and tried again, then got the original error again.

    The solution I found is this:

    On the server, go to Administrative Tools – Services:

    Service: "ASP.NET State Service" had Startup Type set to Manual, and was not running.

    Changed Startup Type to Automatic, and started it. (Right-click on “ASP.NET State Service” – Properties to change settings). Then it worked.

    Hope this helps.
    Scott

    Saturday, February 16, 2008 12:52 AM
  • User1497433748 posted

    2 HiTech2k

    Hello,

    I've got the 100% same problem with only difference that it crashes immediately when I'm trying to write something to session, but works ok when I'm reading it. I've reinstalled iis asp.net config like you described but it didn't help. Any suggestions ?

     

    Tuesday, March 18, 2008 1:25 PM
  • User-786558423 posted

    Thanks ! I am working on IIS 7 and just checking the Startup solved it for me!

    Tuesday, October 27, 2009 6:11 AM
  • User-182294989 posted

    Hi Scott,

     

    Your tip works for me.

     

    thanks for your information and shared.

     

    rgds,
    mmx 

    Wednesday, August 25, 2010 9:24 PM
  • User-2084896922 posted

    I got the same error again, 2 years later, just after I did an automatic security update to Microsoft .NET Framework. I looked in Services at "ASP.NET State Service". It was automatic, but it didn't say it was started. So I started it and then my web site worked again.

    Tuesday, October 5, 2010 11:41 PM
  • User-1793376908 posted

    Hi I tried the above and still got the same error.

    So I went into web config file and saw seesion sate mode was set to "instate" and I changed that to "InProc" and it worked

    < sessionState mode="InProc" timeout="30" />

    thanks

    Flor

    Tuesday, November 16, 2010 12:07 PM
  • User-2084896922 posted

    I got this error again, but for a different reason. I have an ASP.NET web site using ReportViewers. Since the report definition can't be changed for a ReportViewer control, I had 1 control for each report definition on the web page. Depending on which report the user selected, I had to hide unused reportviewer controls, make the selected one visible, and manage the other properties of them. When I got to 5 different reports, I decided to do something different. I put a Literal control on the page, and made a different page with a single ReportViewer control. Now when the user selects a report I just put the page containing the ReportViewer in the Literal and it works with just one ReportViewer. But the downside of this is after bringing up about a dozen reports, the web site bogs down. Continuing to pull up reports causes the error (Unable to make the session state request to the session state server). I sometimes get other errors (Exception of type 'System.OutOfMemoryException' was thrown.). This occurs on an individual session basis; one user can get bogged down and other users are fine. The server did not have problems; no exceptional processor, memory, or network usage occurred.

    Apparently when the ReportViewer is in an embedded page, its view state never gets cleared. So all previous reports remain in memory for each session. To get around this problem, I executed Session.Clear(). This will clear out all session variables also, so I had to put session variables into local variables, execute Session.Clear(), then write session variables back.

    Monday, April 25, 2011 10:20 PM
  • User1944386031 posted

    OUR application does not open new windows. and Users are also stupid enough to not work in multiple windows and we display ONE report at a time. So We are killing the other reports Binarys from session. Code is Below. 

    try
                {
                    Session["int" + j++.ToString()] = DateTime.Now.ToString();
                    reportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local;
                    reportViewer1.LocalReport.EnableHyperlinks = true;
                    reportViewer1.LocalReport.ReportPath = "C:\\softwares\\abk.rdlc";
                    ReportDataSource rds = new ReportDataSource(@"abktest", Dataget());
                    reportViewer1.LocalReport.DataSources.Add(rds);
                    reportViewer1.Visible = true;
                    reportViewer1.EnableViewState = true;
                    List<string> lts = new List<string>();
                    lts.Clear();
    
                    if (Session.Count > 0)
                    {
                        foreach (string i in Session.Keys)
                        {
                            if (Session[i].GetType().FullName == "Microsoft.Reporting.WebForms.ReportHierarchy")
                            {
                                lts.Add(i);
                                //Session.Remove(i);
                            }
                        }
                    }
    
                    foreach (string s in lts)
                    {
                      Session.Remove(s);
                    }
    
                    for (int f = 0; f < j; f++)
                    {
                        Response.Write("current other session variables are : " + Session["int" + f.ToString()].ToString());
                    }
                    
                }
                catch(Exception eEx)
                {
                    Response.Write(eEx.Message + eEx.ToString());
                }
    Thursday, July 28, 2011 8:20 AM
  • User1944386031 posted

    We are Now thinking of creating a session Pool of reportviewer report sessions. we will keep Say 10 Report session only and kill older ones if number of report session goes beyond 10. thereby session state will not get exhausted and this error will not come. 

    BELOW IS CODE TO DO IT IN MUCH MORE ELEGENT WAY

     private static bool INIT = false;
            private static int m_AllocCount;
            public const string SESSION_REPORT_KEYS = "SessionReportKeys";
            public const string REPORT_SESSION_INFO = "Microsoft.Reporting.WebForms.ReportHierarchy";
            Queue<string> QSessionReportKey;
            /// <summary>
            /// Property to USE the Alloc Count variable
            /// </summary>
            public static int AllocCount
            { 
                get {
                if (!INIT)
                        LoadConfiguration();
                return m_AllocCount;
                }
            }
            /// <summary>
            /// Report session allocation count depending upon server configuartion bigger the server allocation count is More 
            /// read from web configuration file
            /// </summary>
            private static void LoadConfiguration()
            {
                m_AllocCount = Convert.ToInt32(ConfigurationManager.AppSettings["AllocCount"]);
                INIT = true;
            }
    
    
    
    private void ConfigureReportSession()
            {   
                //begin the session if it does not exists
                if (Session[SESSION_REPORT_KEYS] != null)
                {
                    QSessionReportKey = (Queue<string>)Session[SESSION_REPORT_KEYS];
                }
                else
                {
                    QSessionReportKey = new Queue<string>();
                    Session[SESSION_REPORT_KEYS] = QSessionReportKey;
                }
    
                //find all the session keys for reportViewer in session variable by applying loop
                IEnumerable<string> SessionReportKeys = from sKeys in Session.Keys.Cast<string>()
                                                 where Session[sKeys].GetType().FullName == REPORT_SESSION_INFO
                                                 select sKeys;
    
                //if the keys Do Not exists in Session Add it to the session Queue
                if (SessionReportKeys != null && SessionReportKeys.Count() > 0)
                {
                    SessionReportKeys.ToList<string>().ForEach(keys =>
                    { 
                     if(!QSessionReportKey.Contains(keys))
                     {
                         QSessionReportKey.Enqueue(keys);
                     }
                    });
                }
    
                //If Queue has exceeded the valid limit delete the variables
                if (QSessionReportKey != null && QSessionReportKey.Count > AllocCount)
                {
                    for (int i = 0; i < AllocCount - QSessionReportKey.Count; i++)
                    {
                        string sRemoveSession = QSessionReportKey.Dequeue();
                        Session.Remove(sRemoveSession);
                    }
                }
                //Reinsert the diction of session keys
                Session.Remove(SESSION_REPORT_KEYS);
                Session[SESSION_REPORT_KEYS] = QSessionReportKey;
            }
    Friday, July 29, 2011 2:32 AM
  • User1944386031 posted

    WE have exactly Pointed the issue related to report viewers controls its due to Partial page postback. in case of complete page post back the report viewer session is cleared. But in case of Update panel, IFRAMES and master pages Due to complete rendering does not occure. this error comes. For users using vs 2008+ then they can start using Reportviewer 10 because it has this issue resolved.

    Tuesday, August 2, 2011 4:45 AM
  • User216219501 posted

    Like many others, I was having the same issue.  I am on Windows 10 and tried to run a web project that was created in VS 2005 (that I upgraded to run in VS 2010).  I changed mine to automatic, but it still didn't work.  I changed it back to manual and after seeing this post started the service and everything worked! :)  Thank you so much.  This issue was driving me crazy.

    Tuesday, November 29, 2016 9:51 PM