9

I just tried to deploy a WebApi application on a Windows 2008R2 with IIS 7.0, with IIS Manager untouched until now.

The App runs on our dev server (same Win and IIS version) without hassle. On the deployment server,

  • .NET Framework 4.5 is installed,
  • ASP.NET Feature is installed and
  • Windows authentication is installed

When I call an URL that should map to ASP.NET, the error is

      HTTP Error 404.0

       Module IIS Web Code
 Notification MapRequestHandler
      Handler StaticFile
   Error code 0x80070002
Requested URL http://localhost:80/myapp/api/GetUserConfig
Physical Path C:\inetpub\wwwroot\myapp\api\GetUserConfig
 Logon Method Negotiate
   Logon User ADDOMAIN\Administrator

Handler StaticFile seems important - as far as I can tell, the cause is that ASP.NET does not correctly handle the URL. Where can I start searching for the actual root of this problem?

I should add that multiple other deployments, all in Windows 2012 environments, were successful.

Alexander
  • 19,906
  • 19
  • 75
  • 162
  • Have you looked at the config file? Does everything seem in order? – Mike_G Sep 30 '14 at 17:46
  • Have you enabled static content feature of iis? See this blog for how to: http://brendan.enrick.com/post/IIS-7-Not-Serving-Static-Files – Avner Oct 02 '14 at 04:42
  • My bad I misread your question. Sounds like a possible duplicate of https://stackoverflow.com/questions/9703090/http-404-page-not-found-in-web-api-hosted-in-iis-7-5 – Avner Oct 02 '14 at 11:58

4 Answers4

1

Microsoft should definitely put a version at "ASP.NET" Feature in the installer.

WHen you install ASP.NET feature on Windows 2008, this enables ASP.NET 3.5, while I require ASP.NET 4.

So after having installed .NET Framework v4, I would go forward and register ASP.NET 4 with IIS:

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

Source:

https://alexanderzeitler.com/articles/HTTP-Error-4040---Not-Found-(MapRequestHandler--StaticFile)-when-deploying-WCF-Web-API-on-IIS-7x/

Alexander
  • 19,906
  • 19
  • 75
  • 162
  • Just a notice: the link in your answer is dead – Hoàng Long Nov 06 '15 at 02:49
  • @HoàngLong Thanks, I updated the answer accordingly. – Alexander Nov 06 '15 at 19:12
  • I'm having this same problem; IIS is handling the request as if it were a static file request, even though it clearly maps to a controller action. But I have another web api application working correctly on the same server using the same application pool, the same version of .net, et etc., so I don't think I'm missing any server side software. The Global.asax and Web.config and WebApiConfig.cs files are exactly the same. The controller action I'm mapping to doesn't require any parameters. I just don't get what could possibly be causing this. – Shavais May 20 '16 at 18:41
  • @Shavais you should make a question for that. Before you make a new question, make sure that the bin folder contains all referenced libraries. I had the same issue when one DLL was missing in the bin folder. – Alexander May 20 '16 at 20:42
  • After posting that comment, I found that using a url that doesn't contain the controller name does call the action. So there's some sort of routing configuration issue. But I'm using attribute routing, and i'm using {controller} in the route template.. and all that is exactly the same as it is in the other solution which is working fine. Ugh. Yeah, I'll make another question if I can't figure it out here shortly. – Shavais May 23 '16 at 15:34
  • I just found that if I explicitly set a [RoutePrefix("controllername")] attribute on the controller class, the routing starts working correctly. The controller classes in the other solution don't have route prefix attributes, and the action route attribute urls don't include the controller prefix, but they're working fine, so I don't know why the route prefix is required in the new solution. – Shavais May 23 '16 at 16:14
0

I had a similar issue to this using Owin. Clearing Temporary ASP.NET Files fixed it. Hope this helps someone.

randomsolutions
  • 2,075
  • 1
  • 19
  • 22
0

If you're trying to call an extensionless URL, there's an official hotfix for this: https://support.microsoft.com/en-us/help/980368/a-update-is-available-that-enables-certain-iis-7.0-or-iis-7.5-handlers-to-handle-requests-whose-urls-do-not-end-with-a-period

Oran Dennison
  • 3,237
  • 1
  • 29
  • 37
0

Just had the same behavior in ASP.Net 4.6.2 on IIS 10 (Windows Server 2016) but it worked on IIS 8.5 (Windows Server 2012 R2). The result was http 404.0, Handler: StaticFile. I solved it by adding the ExtensionlessUrl-handler to web.config:

    <handlers>
        <remove name="ExtensionlessUrl-Integrated-4.0" />
        <add name="ExtensionlessUrl-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers>

The name seems to be important! name="ExtensionlessUrl-Integrated-4.0" works but ExtensionlessUrlHandler-Integrated-4.0 just has no effect.