Session null in ASP.Net MVC Controller Constructors

前端 未结 6 1704
北海茫月
北海茫月 2020-11-27 13:27

Why is Session null in the constructors of Controllers? It can be accessed from Action methods. Presumably, because the MVC Routing framework is responsible for newing-up a

6条回答
  •  萌比男神i
    2020-11-27 13:54

    This answer might be useful for some people

    If we override Initialize method then we have to initialize base class with request context : base.Initialize(requestContext);

    protected override void Initialize(RequestContext requestContext)
            {
                base.Initialize(requestContext);
               
    
            }
    

提交回复
热议问题