I'm trying to get a user ID stored in cookies via a common Controller file, which I can access throughout the site.
I have created FunctionsController
as a controller, with content as follows:
public static int loggedinUser()
{
return Convert.ToInt32( request.Cookies["userid"].Value);
}
I am unable to request any cookie items even if I tried with:
HttpRequestBase request = controllerContext.HttpContext.Request;
I don't have a problem accessing cookies in ASP.NET MVC using a standard access statement such as:
Request.Cookies["someCookie"]
Your sample had a lower-cased "r" in "request.Cookies". Could that be your problem?