Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access cookies from ASP .NET MVC 3 _Layout View

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 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?

like image 681
Alex Avatar asked Feb 23 '23 06:02

Alex


1 Answers

Use @HttpContext.Current.Request

like image 127
Ofer Zelig Avatar answered Mar 09 '23 10:03

Ofer Zelig