I want to use the properties Request
, Response
the class System.Web.Mvc.Controller
to set and read cookie files in HTTP-requests and responses. The reason for this is that it eliminates the need to write utility classes that are read from queries and populate data in some auxiliary class. I can push all such code into the user base controller (from which all my controllers are derived).
So, I have the following code in my "BaseController"
if (Request != null)
{
HttpCookie authCookie = Request.Cookies[FormsAuthentication.FormsCookieName];
if (authCookie != null)
{
HttpContext.User = new GenericPrincipal(new GenericIdentity(authCookie.Value), null);
Thread.CurrentPrincipal = HttpContext.User;
}
}
but Request
always null. How is it populated?
Suhas source
share