ASP.NET MVC on IIS falls through to the static file handler
Asked Answered
T

5

25

I have a problem with an ASP.NET MVC site.

These are the details:

  1. ASP.NET MVC 2
  2. ASP.NET 4 integrated pipeline
  3. IIS 7.5 on Windows Web Server 2008 R2

Whenever I make a request for the app I get the "HTTP Error 404.0 - Not Found"-error and the detailed error information shows it is the static file handler that reports the error:

  • Module: IIS Web Core
  • Notification: MapRequestHandler
  • Handler: StaticFile
  • Error Code: 0x80070002

meaning that the request never entered the MVC stack.

I should note that the IIS already serves a ASP.NET MVC 3 on the same app pool and a MVC 2 on a ASP.ENT 2 app pool. So it's the combo ASP.NET 2 on the ASP.NET 4 app pool that are giving me headaches.

Basically I want to upgrade the app from ASP.NET MVC 2 on a ASP.NET 2.0 app pool to a ASP.NET MVC 2 on a ASP.NET 4.0 app pool.

So any ideas?

Twayblade answered 4/8, 2011 at 12:49 Comment(0)
C
31

I see you fixed your issue, but for anyone googling:

I had this issue and in my case I just needed to register ASP.NET 4 with IIS. I was deleting and re-adding webs to fix other issues and simply forgot to do that. The command that worked for me was:

C:\Windows\Microsoft.NET\Framework64\v4.0.30319>aspnet_regiis -i

Your own .net version may be different, especially if you are in the future, so the above path may not be exactly right.

Cheese answered 14/10, 2011 at 18:20 Comment(1)
I think the version number is important here. I tried the same, but in the wrong .net Framework version. Just putting it down here, just in case someone missed that point. This worked for me.Githens
L
13

I had the same problem when I installed IIS after installing Visual Studio, etc.

I was able to fix the problem by changing my Web.config file, adding the runAllManagedModulesForAllRequests="true" to the <modules> tag:

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

(More details/copied from here: http://www.west-wind.com/weblog/posts/2011/Mar/27/ASPNET-Routing-not-working-on-IIS-70)

Lowson answered 29/10, 2012 at 22:9 Comment(2)
This option shouldn't be set because results in all requests including all static files being sent to managed handlers and this results in increased memory and CPU usage. May get unnoticed on low traffic sites but once IIS will serve megabytes of images, html, js, css and other static content per second your server will crash.Hayrack
Just a rebuttal to @user3285954's comment, the increased memory and CPU usage is almost always negligible. I've worked on some pretty high-traffic sites, and this setting has never caused a problem for me. I'd suggest trying it first, and see if it actually creates a performance problem; it probably won't.Lowson
J
1

Chris' answer got me to check whether the app pool was actually configured for .net 4. Sure enough, this server defaults to creating 32-bit .net 2 pools in classic mode.

Ensure that your app is using 4.0 and you'll probably want Integrated pipeline for all new development. 32/64 is mainly up to your dependencies. The default is leaving "allow 32 bit allocations" set to false.

Jewett answered 20/3, 2018 at 16:48 Comment(0)
L
0

In my case, a similar error was thrown because StaticFile Handler was disabled / not working properly. I eventually fixed it by removing the handler and re-adding it through the web.config. Also, in case of a 403.3 error, change the RequireAccess-property value from "Write" to "Read"

<configuration>
    <system.webServer>
        <handlers>
           <remove name="StaticFile"
            <add 
                name="StaticFile" 
                path="*" verb="*" 
                modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule" 
                resourceType="Either" 
                requireAccess="Read" />
        </handlers>
    </system.webServer>
</configuration>
Loyalty answered 28/8, 2020 at 15:58 Comment(0)
T
-7

So I found the error. There was a left over default document in the root, which isn't necessary for apps using the integrated pipeline. Also some changes to Global.ascx and route registration was neessary, but after that it worked.

Twayblade answered 5/8, 2011 at 13:56 Comment(2)
Could you expand on the solution? What changes to the global.asax for instance?Caroylncarp
Solution doesn't really seem to tie to the problem.Longsome

© 2022 - 2024 — McMap. All rights reserved.