Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<h1>HttpModules are an alternative to global.asax</h1> <p>(see also <a href="https://www.codeguru.com/csharp/.net/net_asp/article.php/c19389/HTTP-Handlers-and-HTTP-Modules-in-ASPNET.htm" rel="nofollow noreferrer">https://www.codeguru.com/csharp/.net/net_asp/article.php/c19389/HTTP-Handlers-and-HTTP-Modules-in-ASPNET.htm</a><br> <a href="http://codebetter.com/blogs/karlseguin/archive/2006/06/12/146356.aspx" rel="nofollow noreferrer">http://codebetter.com/blogs/karlseguin/archive/2006/06/12/146356.aspx</a> )</p> <p>HttpModules are registered in web.config; which, conveniently, <em>is</em> customizable at directory level. So every directory can have its own unique set of modules (that are inherited in lower directories). All modules have the same functionality as those found in global.asax .</p> <p>Basically, every page request gets passed through <em>every</em> registered module before it ever gets to the actual page code itself. This happens regardless of what kind of request it is:</p> <pre> "page.aspx" "page.html" | | ( | module 1 | ) ( | module 2 | ) ( | module 3 | ) V V (handler 1) (handler 2) </pre> <p>((a much better picture and description can be found at <a href="https://www.codeguru.com/csharp/.net/net_asp/article.php/c19389/HTTP-Handlers-and-HTTP-Modules-in-ASPNET.htm" rel="nofollow noreferrer">https://www.codeguru.com/csharp/.net/net_asp/article.php/c19389/HTTP-Handlers-and-HTTP-Modules-in-ASPNET.htm</a> ))</p> <p>So then all you need to do is define your code as a module instead of in global.asax . If the user isn't authenticated, then: <code>response.redirect("login.aspx")</code> will stop control from ever reaching the handler and parsing/returning/running the requested page.</p> <p>It's a little more complicated than that, so a better description/tutorial can be found at the codeguru website.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload