在公网上布署Web Api的时候,不能调用,返回404

在internet上布署web API做的站点时,发现不能调用web api的任何action, 返回404. 经过很多的努力,也找不到原因,环境是win server 2008, IIS 75. net framework 4.5.  后来,在网上找了一个答案,试了下,可以,但还是不知道原因,因为在公司里面的服务器布署都没有问题,只是在IDc提供的虚机才出现这种问题,而且是所有的机器都是一样的问题。解决办法:

在web.config中

Adding the following to the web.config file worked for me:

<system.webServer>
  <modules>
    <remove name="UrlRoutingModule-4.0" />
    <add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="" />
  </modules>
</system.webServer>

参考:http://stackoverflow.com/questions/9703090/http-404-page-not-found-in-web-api-hosted-in-iis-7-5
原文地址:https://www.cnblogs.com/sdikerdong/p/4566825.html