Sitecore 10.1.0 Helix Visual Studio Project Publish Issue - Value cannot be null. Parameter name: sessionStateBehaviorResolver

Error:


Server Error in '/' Application.

Value cannot be null.

Parameter name: sessionStateBehaviorResolver

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.ArgumentNullException: Value cannot be null.

Parameter name: sessionStateBehaviorResolver


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:



[ArgumentNullException: Value cannot be null.

Parameter name: sessionStateBehaviorResolver]

   Sitecore.Diagnostics.Assert.ArgumentNotNull(Object argument, String argumentName) +63

   Sitecore.Owin.Extensions.AppBuilderExtensions.SetSessionStateBehaviorResolver(IAppBuilder app, SessionStateBehaviorResolver sessionStateBehaviorResolver) +54

   Sitecore.Owin.Startup.Configuration(IAppBuilder app) +28


[TargetInvocationException: Exception has been thrown by the target of an invocation.]

   System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) +0

   System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) +132

   System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +146

   Owin.Loader.<>c__DisplayClass19_1.<MakeDelegate>b__0(IAppBuilder builder) +93

   Owin.Loader.<>c__DisplayClass9_0.<LoadImplementation>b__0(IAppBuilder builder) +248

   Microsoft.Owin.Host.SystemWeb.OwinAppContext.Initialize(Action`1 startup) +951

   Microsoft.Owin.Host.SystemWeb.OwinBuilder.Build(Action`1 startup) +51

   Microsoft.Owin.Host.SystemWeb.OwinHttpModule.InitializeBlueprint() +101

   System.Threading.LazyInitializer.EnsureInitializedCore(T& target, Boolean& initialized, Object& syncLock, Func`1 valueFactory) +139

   Microsoft.Owin.Host.SystemWeb.OwinHttpModule.Init(HttpApplication context) +166

   System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +587

   System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +173

   System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +255

   System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +347


[HttpException (0x80004005): Exception has been thrown by the target of an invocation.]

   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +552

   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +122

   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +737


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


Cause:

The new Visual Studio project I published, didn't have the web.config build action set to none. As  a result, the web.config file in the web root was overwritten. The original web.config file normally gets saved with .bak extension in the same location so, I restored the same. In the Visual Studio project's config file, I ensured to set the build action to none so that future publish  doesn't overwrite the web root web config.


Comments