accessing HttpContext.Request in a controller's constructor

前端 未结 4 1611
离开以前
离开以前 2020-12-12 20:30

I\'m following this ASP.NET MVC tutorial from Microsoft:

My code is slightly different, where I\'m trying to access HttpContext.Request.IsAuthenticated

4条回答
  •  长情又很酷
    2020-12-12 20:54

    I would suggest you use:

     System.Web.HttpContext.Current.Request
    

    Just remember System.Web.HttpContext.Current is threadstatic, but if you don't use additional thread the solution works.

提交回复
热议问题