更新时间:2023-02-25 20:10:38
Context
和HttpContext
之间的命名有些混乱.您可以使用Context
属性在视图中访问HttpContext:
The naming between Context
and HttpContext
is somewhat confusing. You can access the HttpContext in a view using the Context
property:
@{ int x = Context.Session.GetInt32("test"); }
MVC存储库中还有一个与此相关的待解决问题: https://github.com/aspnet/Mvc/Issues/3332
There is also a pending issue at the MVC repo regarding this: https://github.com/aspnet/Mvc/issues/3332