6

I am working on .Net Web API which is working fine in debug as well as on localhost IIS but when i publish this to server it starts giving following error :-
"Message": "No HTTP resource was found that matches the request URI

On server, we have application folder under default site for this API, but it's working fine in application folder under local IIS's default site so that should not be the problem.

Now i tried setting proper verb in handler as specified in following url but didn't work:
HTTP 404 Page Not Found in Web Api hosted in IIS 7.5

Also i have MVC4 installed on server as suggested on following url:
.NET Web Api - 404 - File or directory not found

Also WebDav module, handler may give error so i also tried removing it but it's giving same error.

Here is the Web.config section for module, handler settings :-

<modules runAllManagedModulesForAllRequests="true" />
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="*" modules="IsapiModule" 
       scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" 
       preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
  <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="*" modules="IsapiModule" 
       scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" 
       preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
  <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>

I am not playing with routes anywhere. Am i missing something regarding settings/configuration in web.config or server IIS ?

Community
  • 1
  • 1
user621504
  • 89
  • 1
  • 1
  • 5
  • Are all HTTP methods giving you this error, basically any route, or only specific verbs (e.g. PUT and DELETE)? Have you tried classic / integrated modes (IIS)? – Joanna Derks Apr 24 '13 at 19:48
  • Yes all HTTP methods are giving this error. I am using integrated mode in IIS 7.5. – user621504 Apr 25 '13 at 01:47
  • Did you solve the problem? I'm having the same right now... – Slauma May 28 '13 at 18:04
  • For me the reason of the problem turned out to be a missing assembly: http://stackoverflow.com/a/16825254/270591. Maybe you could check this in your project with the help of Kiran Challa's testing code from here: http://stackoverflow.com/a/16674992/270591 – Slauma May 29 '13 at 23:11

3 Answers3

1

This works for me:

<remove name="WebDAV"/>

I don't know why it is installed on the server. But this seems to have interference with extensionless handlers

From IIS (http://www.iis.net/learn/install/installing-publishing-technologies/installing-and-configuring-webdav-on-iis):

Microsoft released a new WebDAV extension module that was completely rewritten for Internet Information Services (IIS) 7 and above on Windows Server® 2008. This new WebDAV extension module incorporated many new features that enable Web authors to publish content better than before, and offers Web administrators more security and configuration options. Microsoft has released an update to the WebDAV extension module for Windows Server® 2008 that provides shared and exclusive locks support to prevent lost updates due to overwrites.

1

Another potential reason for this is if the

    GlobalConfiguration.Configure(WebApiConfig.Register);

is after

    RouteConfig.RegisterRoutes(RouteTable.Routes);

in global.asax.cs

It needs to be before, otherwise the default RouteConfig route 'eats' the WebAPI route - and attempts to map API requests to a controller called API...

Andiih
  • 12,285
  • 10
  • 57
  • 88
0

Change to:

<validation validateIntegratedModeConfiguration="false" />
<modules>
  <remove name="WebDAVModule"/>
</modules>
<handlers>
  <remove name="WebDAV"/>
  <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
  <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
  <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
  <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
  <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
  <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>