Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我是 MVC3 的新手,你能告诉我并展示一个示例,我如何使用 session 来检查用户是否在不同的视图中登录?
如果您使用的是 asp.net 会员资格,则无需访问会话即可检查用户状态。
您可以使用 :
Requrest.isAuthenticated //(HttpRequest.IsAuthenticated Property (System.Web))
如果用户已通过身份验证,则返回 true ,否则返回 false 。
访问会话
Session["variableName"] = "value";