Created
April 7, 2013 11:34
-
-
Save gabrielgreen/5330126 to your computer and use it in GitHub Desktop.
SuppressFormsAuthenticationRedirectModule.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SuppressFormsAuthenticationRedirectModule : IHttpModule | |
{ | |
public void Init(HttpApplication context) | |
{ | |
context.PostReleaseRequestState += OnPostReleaseRequestState; | |
} | |
private void OnPostReleaseRequestState(object source, EventArgs args) | |
{ | |
var context = (HttpApplication)source; | |
var response = context.Response; | |
var request = context.Request; | |
if (response.StatusCode == 401 && request.Headers["X-Requested-With"] == "XMLHttpRequest") | |
context.Response.SuppressFormsAuthenticationRedirect = true; | |
} | |
public void Dispose() | |
{ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment