c# - Session state - strange behaviour when injecting with Autofac -


consider have autofac configured in mvc app this:

builder.registermodule(new autofacwebtypesmodule()); 

it needed inject session state:

internal class defaultsessionaccess : isessionaccess {     private readonly httpsessionstatebase session;      public defaultsessionaccess(httpsessionstatebase session)     {         this.session = session;     }      public void put(string key, object @object)     {         this.session.add(key, @object);     } } 

the problem following code put in controller:

public class somecontroller : controller {     private isessionaccess session;      public somecontroller(isessionaccess session)     {         this.session = session;     }       public actionresult someaction()     {         this.session.put("key", "value");         var isnull = this.httpcontext.session["key"] == null;     } } 

the problem on local machine (iis) isnull false - object saved in session. when deploy azure, isnull is... true! somehow object not saved in session.

when put directly:

 this.httpcontext.session["key"] = "value"; 

it works fine on both servers.

according documentation, httpcontext.current.session registered httpsessionstatebase.

why happens?


Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -