Permalink
Browse files

added additional check for application/json request

  • Loading branch information...
1 parent d3c135f commit 97338a21faa4b92302017354e9e9a970b2a671bc @desunit desunit committed Nov 27, 2012
Showing with 3 additions and 2 deletions.
  1. +3 −2 CustomAuthenticationMvc/Helper/SuppressFormsAuthenticationRedirectModule.cs
View
5 CustomAuthenticationMvc/Helper/SuppressFormsAuthenticationRedirectModule.cs
@@ -39,8 +39,9 @@ private void OnPostReleaseRequestState(object source, EventArgs args)
var response = context.Response;
var request = context.Request;
- if (response.StatusCode == 401 && request.Headers["X-Requested-With"] ==
- "XMLHttpRequest")
+ if (response.StatusCode == 401 && (request.Headers["X-Requested-With"] == "XMLHttpRequest"
+ || (request.AcceptTypes != null && request.AcceptTypes.Any(t => string.Compare(t, "application/json", StringComparison.InvariantCulture) == 0)))
+ )
{
SuppressAuthenticationRedirect(context.Context);
}

0 comments on commit 97338a2

Please sign in to comment.