Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Global.asax Application_BeginRequest not firing unless physical file exists - 404

I use URL rewriting (HttpContext.Current.RewritePath(...)) inside Global.asax so the physical files mostly don't exist. Everything was working fine until I had to remove site from IIS (8.5) and add it again.

And now I get 404 not found for every request. Example http://localhost/site/article123 And Global.asax Application_BeginRequest event not even firing.

If I however will add empty default.aspx file in folder /site/article123 everything starts to work fine with URL being correctly rewritten.

Files have not changed, so it's ought to be the problem with IIS configuration.

I do have following inside web.config:
<modules runAllManagedModulesForAllRequests="true">

Project in IIS is set as an Application with Application Pool .NET v2.0 Classic

Edit:
Same story in IIS 8.0

like image 556
Sergej Popov Avatar asked Feb 13 '23 14:02

Sergej Popov


1 Answers

The problem was in Managed Pipeline Mode set as classic. Switching from classic to integrated by changing Application pool from .NET v2.0 Classic to .NET v2.0 sorted the problem.

As I understood this: in classic mode IIS is managing requests, while in intergated mode incoming IIS requests map to the ASP.NET engine.

More on pipeline modes: What is the difference between 'classic' and 'integrated' pipeline mode in IIS7?

like image 76
Sergej Popov Avatar answered Feb 16 '23 14:02

Sergej Popov