How to add an exclusion list to an HTTP Module in ASP.NET MVC

When writing your own HTTP Module you will need to have an exclusion list, so that not all HTTP request are intercepted by this module. Like for example: HTTP requests for CSS, JS, Images and even Html templates.

Here is what I used in one of our recent projects

private bool ShouldProcessRequestForSignUp(HttpRequest request)
bool isAnAjaxRequest = request.RequestContext.HttpContext.Request.IsAjaxRequest();
bool isRequestIsForLogoff = request.Url.AbsolutePath.ToLower().Contains("/account/logoff");
bool isRequestIsForLogin = request.Url.AbsolutePath.ToLower().Contains("/account/login");
bool isRequestForResources = (request.Url.AbsolutePath.ToLower().Contains("content") || request.Url.AbsolutePath.ToLower().Contains("scripts"));
if (isAnAjaxRequest)
return false;
if (isRequestFortheSignupPage || isRequestIsForLogoff || isRequestIsForLogin)
return false;
if (isRequestForResources)
return false;
return true;
One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.