ASP.NET Session has expired (SSRS environment)

Published Mar 13 2020 01:43 PM 3,436 Views
Microsoft

If you are hosting SSRS environment on multiple IIS servers, you will need to use a common State Server or SQL Server to store session data. Please note that using In-Process mode or using State Server Mode in the server itself will cause session errors such as “ASP.NET Session has expired”. In order to avoid this issue:

 

In the web.config file:

  • Set enableSessionState to True. Example:
<pages buffer="true" validateRequest="true" enableSessionState="false" enableViewState="true" viewStateEncryptionMode="Always" controlRenderingCompatibilityVersion="4.0" clientIDMode="AutoID">
  • Make sure that Session State is not disabled in pages. If there is enableSessionState parameter in the Page directive, set it to True. Example:
<%@Page enableSessionState="true">
  • There should be stateConnectionString defined in the. IIS servers should point to a common server to store session information. Example:
<sessionState mode="StateServer" stateConnectionString="tcpip=SampleStateServer:42424" cookieless="false" timeout="20"/>
  • To set up a separate server as State Server, install .NET Framework and set the registry key below to “1”. ASP.NET State Service should be running.
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\aspnet_state\Parameters\AllowRemoteConnections

References:

%3CLINGO-SUB%20id%3D%22lingo-sub-1227797%22%20slang%3D%22en-US%22%3EASP.NET%20Session%20has%20expired%20(SSRS%20environment)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1227797%22%20slang%3D%22en-US%22%3E%3CP%3EIf%20you%20are%20hosting%26nbsp%3B%3CSTRONG%3ESSRS%26nbsp%3B%3C%2FSTRONG%3Eenvironment%20on%20multiple%20IIS%20servers%2C%20you%20will%20need%20to%20use%20a%20common%26nbsp%3B%3CSTRONG%3EState%20Server%3C%2FSTRONG%3E%26nbsp%3Bor%26nbsp%3B%3CSTRONG%3ESQL%20Server%3C%2FSTRONG%3E%26nbsp%3Bto%20store%20session%20data.%20Please%20note%20that%20using%20In-Process%20mode%20or%20using%20State%20Server%20Mode%20in%20the%20server%20itself%20will%20cause%20session%20errors%20such%20as%20%E2%80%9C%3CSTRONG%3EASP.NET%20Session%20has%20expired%3C%2FSTRONG%3E%E2%80%9D.%20In%20order%20to%20avoid%20this%20issue%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20the%20web.config%20file%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%20style%3D%22font-weight%3A%20400%3B%22%3ESet%26nbsp%3BenableSessionState%26nbsp%3Bto%26nbsp%3BTrue.%20Example%3A%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%3CPAGES%20buffer%3D%22true%22%20validaterequest%3D%22true%22%20enablesessionstate%3D%22false%22%20enableviewstate%3D%22true%22%20viewstateencryptionmode%3D%22Always%22%20controlrenderingcompatibilityversion%3D%224.0%22%20clientidmode%3D%22AutoID%22%3E%3C%2FPAGES%3E%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CUL%3E%0A%3CLI%20style%3D%22font-weight%3A%20400%3B%22%3EMake%20sure%20that%20Session%20State%20is%20not%20disabled%20in%20pages.%20If%20there%20is%26nbsp%3BenableSessionState%26nbsp%3Bparameter%20in%20the%26nbsp%3BPage%26nbsp%3Bdirective%2C%20set%20it%20to%26nbsp%3BTrue.%20Example%3A%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%26lt%3B%25%40Page%20enableSessionState%3D%22true%22%26gt%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CUL%3E%0A%3CLI%20style%3D%22font-weight%3A%20400%3B%22%3EThere%20should%20be%26nbsp%3BstateConnectionString%26nbsp%3Bdefined%20in%20the.%20IIS%20servers%20should%20point%20to%20a%20common%20server%20to%20store%20session%20information.%20Example%3A%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%3CSESSIONSTATE%20mode%3D%22StateServer%22%20stateconnectionstring%3D%22tcpip%3DSampleStateServer%3A42424%22%20cookieless%3D%22false%22%20timeout%3D%2220%22%3E%3C%2FSESSIONSTATE%3E%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CUL%3E%0A%3CLI%20style%3D%22font-weight%3A%20400%3B%22%3ETo%20set%20up%20a%20separate%20server%20as%20State%20Server%2C%20install%20.NET%20Framework%20and%20set%20the%20registry%20key%20below%20to%20%E2%80%9C1%E2%80%9D.%20ASP.NET%20State%20Service%20should%20be%20running.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3EHKEY_LOCAL_MACHINE%5CSYSTEM%5CCurrentControlSet%5CServices%5Caspnet_state%5CParameters%5CAllowRemoteConnections%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EReferences%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%20style%3D%22font-weight%3A%20400%3B%22%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fprevious-versions%2Faspnet%2Fms178586%2528v%253dvs.100%2529%23state-server-mode%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3EState%20Server%20Mode%20with%20the%20sample%20configuration%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%20style%3D%22font-weight%3A%20400%3B%22%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fiis%2Fapplication-frameworks%2Fscenario-build-an-aspnet-website-on-iis%2Fplanning-step-2-plan-asp-net-settings%23store-session-state-by-using-state-server%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3EPlanning%20for%20State%20Server%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%20style%3D%22font-weight%3A%20400%3B%22%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fiis%2Fapplication-frameworks%2Fscenario-build-an-aspnet-website-on-iis%2Fconfiguring-step-2-configure-asp-net-settings%23store-session-state-by-using-state-server%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3E%3CSPAN%3EStep-by-step%20instructions%20to%20use%20State%20Server%3C%2FSPAN%3E%3C%2FA%3E%3C%2FLI%3E%0A%3C%2FUL%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-1227797%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%20style%3D%22display%3A%20inline%20!important%3B%20float%3A%20none%3B%20background-color%3A%20%23ffffff%3B%20color%3A%20%23333333%3B%20cursor%3A%20text%3B%20font-family%3A%20inherit%3B%20font-size%3A%2016px%3B%20font-style%3A%20normal%3B%20font-variant%3A%20normal%3B%20font-weight%3A%20300%3B%20letter-spacing%3A%20normal%3B%20line-height%3A%201.7142%3B%20orphans%3A%202%3B%20text-align%3A%20left%3B%20text-decoration%3A%20none%3B%20text-indent%3A%200px%3B%20text-transform%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20white-space%3A%20normal%3B%20word-spacing%3A%200px%3B%22%3EIf%20you%20are%20hosting%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%20style%3D%22box-sizing%3A%20border-box%3B%20color%3A%20%23333333%3B%20font-family%3A%20%26amp%3Bquot%3B%20segoeui%26amp%3Bquot%3B%2C%26amp%3Bquot%3Blato%26amp%3Bquot%3B%2C%26amp%3Bquot%3Bhelvetica%20neue%26amp%3Bquot%3B%2Chelvetica%2Carial%2Csans-serif%3B%20font-size%3A%2016px%3B%20font-style%3A%20normal%3B%20font-variant%3A%20normal%3B%20font-weight%3A%20bold%3B%20letter-spacing%3A%20normal%3B%20orphans%3A%202%3B%20text-align%3A%20left%3B%20text-decoration%3A%20none%3B%20text-indent%3A%200px%3B%20text-transform%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20white-space%3A%20normal%3B%20word-spacing%3A%200px%3B%22%3ESSRS%26nbsp%3B%3C%2FSTRONG%3E%3CSPAN%20style%3D%22display%3A%20inline%20!important%3B%20float%3A%20none%3B%20background-color%3A%20%23ffffff%3B%20color%3A%20%23333333%3B%20cursor%3A%20text%3B%20font-family%3A%20inherit%3B%20font-size%3A%2016px%3B%20font-style%3A%20normal%3B%20font-variant%3A%20normal%3B%20font-weight%3A%20300%3B%20letter-spacing%3A%20normal%3B%20line-height%3A%201.7142%3B%20orphans%3A%202%3B%20text-align%3A%20left%3B%20text-decoration%3A%20none%3B%20text-indent%3A%200px%3B%20text-transform%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20white-space%3A%20normal%3B%20word-spacing%3A%200px%3B%22%3Eenvironment%20on%20multiple%20IIS%20servers%2C%20you%20will%20need%20to%20use%20a%20common%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%20style%3D%22box-sizing%3A%20border-box%3B%20color%3A%20%23333333%3B%20font-family%3A%20%26amp%3Bquot%3B%20segoeui%26amp%3Bquot%3B%2C%26amp%3Bquot%3Blato%26amp%3Bquot%3B%2C%26amp%3Bquot%3Bhelvetica%20neue%26amp%3Bquot%3B%2Chelvetica%2Carial%2Csans-serif%3B%20font-size%3A%2016px%3B%20font-style%3A%20normal%3B%20font-variant%3A%20normal%3B%20font-weight%3A%20bold%3B%20letter-spacing%3A%20normal%3B%20orphans%3A%202%3B%20text-align%3A%20left%3B%20text-decoration%3A%20none%3B%20text-indent%3A%200px%3B%20text-transform%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20white-space%3A%20normal%3B%20word-spacing%3A%200px%3B%22%3EState%20Server%3C%2FSTRONG%3E%3CSPAN%20style%3D%22display%3A%20inline%20!important%3B%20float%3A%20none%3B%20background-color%3A%20%23ffffff%3B%20color%3A%20%23333333%3B%20cursor%3A%20text%3B%20font-family%3A%20inherit%3B%20font-size%3A%2016px%3B%20font-style%3A%20normal%3B%20font-variant%3A%20normal%3B%20font-weight%3A%20300%3B%20letter-spacing%3A%20normal%3B%20line-height%3A%201.7142%3B%20orphans%3A%202%3B%20text-align%3A%20left%3B%20text-decoration%3A%20none%3B%20text-indent%3A%200px%3B%20text-transform%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20white-space%3A%20normal%3B%20word-spacing%3A%200px%3B%22%3E%26nbsp%3Bor%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%20style%3D%22box-sizing%3A%20border-box%3B%20color%3A%20%23333333%3B%20font-family%3A%20%26amp%3Bquot%3B%20segoeui%26amp%3Bquot%3B%2C%26amp%3Bquot%3Blato%26amp%3Bquot%3B%2C%26amp%3Bquot%3Bhelvetica%20neue%26amp%3Bquot%3B%2Chelvetica%2Carial%2Csans-serif%3B%20font-size%3A%2016px%3B%20font-style%3A%20normal%3B%20font-variant%3A%20normal%3B%20font-weight%3A%20bold%3B%20letter-spacing%3A%20normal%3B%20orphans%3A%202%3B%20text-align%3A%20left%3B%20text-decoration%3A%20none%3B%20text-indent%3A%200px%3B%20text-transform%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20white-space%3A%20normal%3B%20word-spacing%3A%200px%3B%22%3ESQL%20Server%3C%2FSTRONG%3E%3CSPAN%20style%3D%22display%3A%20inline%20!important%3B%20float%3A%20none%3B%20background-color%3A%20%23ffffff%3B%20color%3A%20%23333333%3B%20cursor%3A%20text%3B%20font-family%3A%20inherit%3B%20font-size%3A%2016px%3B%20font-style%3A%20normal%3B%20font-variant%3A%20normal%3B%20font-weight%3A%20300%3B%20letter-spacing%3A%20normal%3B%20line-height%3A%201.7142%3B%20orphans%3A%202%3B%20text-align%3A%20left%3B%20text-decoration%3A%20none%3B%20text-indent%3A%200px%3B%20text-transform%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20white-space%3A%20normal%3B%20word-spacing%3A%200px%3B%22%3E%26nbsp%3Bto%20store%20session%20data.%20Please%20note%20that%20using%20In-Process%20mode%20or%20using%20State%20Server%20Mode%20in%20the%20server%20itself%20will%20cause%20session%20errors%20such%20as%20%E2%80%9C%3C%2FSPAN%3E%3CSTRONG%20style%3D%22box-sizing%3A%20border-box%3B%20color%3A%20%23333333%3B%20font-family%3A%20%26amp%3Bquot%3B%20segoeui%26amp%3Bquot%3B%2C%26amp%3Bquot%3Blato%26amp%3Bquot%3B%2C%26amp%3Bquot%3Bhelvetica%20neue%26amp%3Bquot%3B%2Chelvetica%2Carial%2Csans-serif%3B%20font-size%3A%2016px%3B%20font-style%3A%20normal%3B%20font-variant%3A%20normal%3B%20font-weight%3A%20bold%3B%20letter-spacing%3A%20normal%3B%20orphans%3A%202%3B%20text-align%3A%20left%3B%20text-decoration%3A%20none%3B%20text-indent%3A%200px%3B%20text-transform%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20white-space%3A%20normal%3B%20word-spacing%3A%200px%3B%22%3EASP.NET%20Session%20has%20expired%3C%2FSTRONG%3E%3CSPAN%20style%3D%22display%3A%20inline%20!important%3B%20float%3A%20none%3B%20background-color%3A%20%23ffffff%3B%20color%3A%20%23333333%3B%20cursor%3A%20text%3B%20font-family%3A%20inherit%3B%20font-size%3A%2016px%3B%20font-style%3A%20normal%3B%20font-variant%3A%20normal%3B%20font-weight%3A%20300%3B%20letter-spacing%3A%20normal%3B%20line-height%3A%201.7142%3B%20orphans%3A%202%3B%20text-align%3A%20left%3B%20text-decoration%3A%20none%3B%20text-indent%3A%200px%3B%20text-transform%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20white-space%3A%20normal%3B%20word-spacing%3A%200px%3B%22%3E%E2%80%9D.%20In%20order%20to%20avoid%20this%20issue%3A%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-TEASER%3E
Version history
Last update:
‎Mar 13 2020 01:43 PM
Updated by: