Hi folks,
I am using the UserData Property of the FormsAuthenticationTicket to store some userspecific information. I have a HelperClass which deserializes this UserData into a custom Object for strongly-typed access. I have my controller setup as follows
public class SomeController : Controller
{
private CookieData _cookieData;
public SomeController()
{
_service = new ForderungsStellerService(new ModelStateWrapper(this.ModelState));
HttpCookie cookie = Request.Cookies[FormsAuthentication.FormsCookieName];
FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(cookie.Value);
_cookieData= GetSessionData.FromCookie(ticket);
}
}
The problem seems to be, that Request is null at controller construction time. When accessing Request.Cookies from an ActionMethod, this snippet is working.
I would like to have the _cookieData object be filled within the constructor for DRY reasons.
Does anyone has a hint on that problem?
best regards...