DotVVM is OWIN middleware , so you need to configure OWIN first to enable the session. First, you need to declare this method, which includes an ASP.NET session:
public static void RequireAspNetSession(IAppBuilder app) {
app.Use((context, next) =>
{
var httpContext = context.Get<HttpContextBase>(typeof(HttpContextBase).FullName);
httpContext.SetSessionStateBehavior(SessionStateBehavior.Required);
return next();
});
app.UseStageMarker(PipelineStage.MapHandler);
}
Then Startup.cscall it in the file :
app.RequireAspNetSession();
Then you can use HttpContext.Current.Session["key"]to access your session state.
source
share