none
IIS, MVC4 API returns 404 Not Found for all API URLs RRS feed

  • Question

  • I am trying to deploy an MVC4 application which implements a REST API. The API works in Visual Studio 2012 in debug mode.

    When I try to deploy it to IIS 7 I can visit and see a 'normal' MVC4 web page, but when I request one of the API URLs I get 404 Not found.

    I have tried many of the proposed solutions to this which I found on Stack Overflow but none of them work.

    Another relevant fact is that this application has to run in 32 bit mode because it calls into a 32 bit DLL which is written in C++.

    This is the section of web.config which I have been editing to try to get this working:

      <system.webServer>
        <validation validateIntegratedModeConfiguration="true" />
    
        <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="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="*" type="System.Web.Handlers.TransferRequestHandler" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode,runtimeVersionv4.0" />
          <add name="AttributeRouting" path="routes.axd" verb="*" type="AttributeRouting.Web.Logging.LogRoutesHandler, AttributeRouting.Web" />
        </handlers>
    
    
        <modules runAllManagedModulesForAllRequests="true">
          <remove name="UrlRoutingModule-4.0" />
          <add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="" />
    
          <add name="BasicAuthHttpModule" type="com.eurotherm.EOS.NavigatorServices.BasicAuthHttpModule" />
        </modules>
      </system.webServer>

    How can I diagnose the cause of this and/or fix the problem which I have?

    Wednesday, October 9, 2013 10:04 AM

Answers

All replies

  • We have fixed it!

    FYI: The key was to clear all existing inherited routing in web.config and then manually force the MVC router to take precedence.

    Wednesday, October 9, 2013 12:46 PM
  • Hi,

    I am very glad that you have solved your problem by yourself.

    If you have any other problem, welcome to post it in the Windows Communication Foundation, Serialization, and Networking forums.

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, October 16, 2013 2:44 AM
    Moderator