public AntiForgeryToken GetCookieToken(HttpRequestMessage httpContext) { CookieHeaderValue cookie = httpContext.Headers.GetCookies(m_config.CookieName).FirstOrDefault(); string cookieValue = cookie?[m_config.CookieName].Value; if (string.IsNullOrEmpty(cookieValue)) { return(null); } return(AntiForgeryTokenSerializer.Deserialize(cookieValue)); }
public AntiForgeryToken GetFormToken(HttpRequestMessage request) { PostData postData = request.GetPostData(); string formValue = postData.FormData[m_config.FormFieldName]; if (string.IsNullOrEmpty(formValue)) { request.QueryParameters().TryGetValue(m_config.FormFieldName, out formValue); } if (string.IsNullOrEmpty(formValue)) { return(null); } return(AntiForgeryTokenSerializer.Deserialize(formValue)); }
private AntiForgeryToken DeserializeToken(string serializedToken) { return(!string.IsNullOrEmpty(serializedToken) ? AntiForgeryTokenSerializer.Deserialize(serializedToken) : null); }