Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save gabrielgreen/5330126 to your computer and use it in GitHub Desktop.
Save gabrielgreen/5330126 to your computer and use it in GitHub Desktop.
SuppressFormsAuthenticationRedirectModule.cs
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