Server Error in '/' Application.

'HttpContext.SetSessionStateBehavior' can only be invoked before 'HttpApplication.AcquireRequestState' event is raised.

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.InvalidOperationException: 'HttpContext.SetSessionStateBehavior' can only be invoked before 'HttpApplication.AcquireRequestState' event is raised.

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:


[InvalidOperationException: 'HttpContext.SetSessionStateBehavior' can only be invoked before 'HttpApplication.AcquireRequestState' event is raised.]
   System.Web.HttpContext.SetSessionStateBehavior(SessionStateBehavior sessionStateBehavior) +166
   System.Web.HttpContextWrapper.SetSessionStateBehavior(SessionStateBehavior sessionStateBehavior) +15
   System.Web.Mvc.MvcRouteHandler.GetHttpHandler(RequestContext requestContext) +45
   System.Web.Mvc.MvcRouteHandler.System.Web.Routing.IRouteHandler.GetHttpHandler(RequestContext requestContext) +12
   CMS.URLRewritingEngine.URLRewriter.RedirectToPageNotFound(SiteNameOnDemand siteName, ViewModeOnDemand viewMode, Boolean alwaysRedirect) +1764
   CMS.URLRewritingEngine.URLRewriter.PageNotFound(SiteNameOnDemand siteName, ViewModeOnDemand viewMode, Boolean alwaysRedirect) +62
   CMS.URLRewritingEngine.URLRewriter.HandlePageNotFound() +73
   CMS.URLRewritingEngine.URLRewritingHandlers.HandlePageNotFound(Object sender, EventArgs e) +49
   CMS.Base.AbstractHandler.CallEventHandler(EventHandler`1 h, TArgs e) +100
   CMS.Base.AbstractHandler.Raise(String partName, List`1 list, TArgs e, Boolean important) +713
   CMS.Base.SimpleHandler`2.RaiseExecute(TArgs e) +95
   CMS.Base.SimpleHandler`2.RaiseExecute(TArgs e) +123
   CMS.Base.SimpleHandler`2.StartEvent(TArgs e) +216
   CMS.Base.ApplicationModule.EndRequest(Object sender, EventArgs e) +42
   System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +201
   System.Web.<>c__DisplayClass285_0.<ExecuteStepImpl>b__0() +26
   System.Web.StepInvoker.Invoke(Action executionStep) +100
   System.Web.<>c__DisplayClass4_0.<Invoke>b__0() +22
   Microsoft.AspNet.TelemetryCorrelation.TelemetryCorrelationHttpModule.OnExecuteRequestStep(HttpContextBase context, Action step) +65
   System.Web.<>c__DisplayClass284_0.<OnExecuteRequestStep>b__0(Action nextStepAction) +55
   System.Web.StepInvoker.Invoke(Action executionStep) +84
   System.Web.<>c__DisplayClass4_0.<Invoke>b__0() +22
   Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule.OnExecuteRequestStep(HttpContextBase context, Action step) +124
   System.Web.<>c__DisplayClass284_0.<OnExecuteRequestStep>b__0(Action nextStepAction) +55
   System.Web.StepInvoker.Invoke(Action executionStep) +84
   System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +100
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +73


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.4690.0