public AntiForgeryToken GetCookieToken(HttpContextBase httpContext) { HttpCookie cookie = httpContext.Request.Cookies[_config.CookieName]; if (cookie == null || String.IsNullOrEmpty(cookie.Value)) { // did not exist return(null); } return(_serializer.Deserialize(cookie.Value)); }
public AntiForgeryToken GetCookieToken(HttpContext httpContext) { var contextAccessor = httpContext.RequestServices.GetRequiredService <IContextAccessor <AntiForgeryContext> >(); if (contextAccessor.Value != null) { return(contextAccessor.Value.CookieToken); } var requestCookie = httpContext.Request.Cookies[_config.CookieName]; if (string.IsNullOrEmpty(requestCookie)) { // unable to find the cookie. return(null); } return(_serializer.Deserialize(requestCookie)); }
private AntiForgeryToken DeserializeToken(string serializedToken) { return((!String.IsNullOrEmpty(serializedToken)) ? _serializer.Deserialize(serializedToken) : null); }