简体   繁体   中英

Application_BeginRequest event is not firing

I'm working with Application_BeginRequest event which is supposed to be triggered when request to some url is made.

protected void Application_BeginRequest(Object sender, EventArgs e)
    {            
        if (HttpContext.Current.Request.Url.ToString() == DummyPageUrl)
        {
            RegisterCacheEntry();
        }
    }

And here is the code I used to request url:

private void HitPage()
    {
        WebClient client = new WebClient();
        client.DownloadData(DummyPageUrl);            
    }

But Application_BeginRequest event is not firing. I have also tried this in web.config:

<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
</modules>

which didn't work. Please help me.

Are you working in global.asax?

try this in Global.asax page....

 void Application_BeginRequest(object sender, EventArgs e)
    {



    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM