Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can also find global.asax file and use one of events of <code>HttpApplication</code> class (for example <code>BeginRequest</code>):</p> <p><a href="http://msdn.microsoft.com/en-us/library/system.web.httpapplication.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/system.web.httpapplication.aspx</a></p> <p><code>HttpApplication</code> has <code>Request</code> property.</p> <p>You can catch every request there, not only related to Controller (images, css, wrong address).</p> <pre><code>public class MvcApplication : System.Web.HttpApplication { protected void Application_BeginRequest(object sender, EventArgs e) { //Request.Have_fun } } </code></pre> <p>If you don't want to write code in global.asax file, you should consider using <code>HttpModule</code>.</p> <p>Create new class with this example code:</p> <pre><code>using System; using System.Web; namespace MyProject { public class MyHttpModule : IHttpModule { public void Init(HttpApplication application) { application.BeginRequest += ApplicationBeginRequest; application.EndRequest += ApplicationEndRequest; } private void ApplicationEndRequest(object sender, EventArgs e) { //do something here with HttpContext.Current.Request } private static void ApplicationBeginRequest(Object source, EventArgs e) { //do something here with HttpContext.Current.Request } public void Dispose() { } } } </code></pre> <p>Add two entries in web.config (registers HttpModule):</p> <pre><code>&lt;system.web&gt; &lt;httpModules&gt; &lt;add name="MyHttpModule" type="MyProject.MyHttpModule" /&gt; &lt;/httpModules&gt; &lt;/system.web&gt; &lt;system.webServer&gt; &lt;modules runAllManagedModulesForAllRequests="true"&gt; &lt;add name="MyHttpModule" type="MyProject.MyHttpModule" /&gt; &lt;/modules&gt; &lt;/system.webserver&gt; </code></pre> <p>Because of changes in IIS7(adding system.webServer section), you have to add two entries in web.config.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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