开发者

Access cookies from ASP .NET MVC 3 _Layout View

开发者 https://www.devze.com 2023-03-29 01:00 出处:网络
I\'m using a default _Layout.cshtml for my layout. Now, I would like to access the Request object, so I could read the Cookies collection, so I could see if user is logged in. How开发者_C百科 can I a

I'm using a default _Layout.cshtml for my layout.

Now, I would like to access the Request object, so I could read the Cookies collection, so I could see if user is logged in. How开发者_C百科 can I achieve that, since the _Layout view doesn't have a Controller? I thought about creating a model for the _Layout view, but the model can't access Request as well. Any thoughts?


Use @HttpContext.Current.Request

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号