asp.net web api部署在Windows服務器上后,按照WebAPI定義的路由訪問,老是出現404,但定義一個靜態文件從站點訪問,卻又OK。
這時,便可以確定是WebAPI路由出了問題,經調查發現是缺少路由處理映射,這時,只需在system.webServer下添加如下配置即可:
<modules> <remove name="UrlRoutingModule-4.0" /> <add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="" /> </modules>