iis 部署webapi常見錯誤及解決方案
錯誤一:
原因:asp.net web api部署在Windows服務器上后,按照WebAPI定義的路由訪問,老是出現404,但定義一個靜態文件從站點訪問,卻又OK。
這時,便可以確定是WebAPI路由出了問題,經調查發現是缺少路由處理映射,這時,只需在system.webServer下添加如下配置即可。是IIS版本問題,上述問題在IIS7.0以下版本中會出現。
解決方案:
在 <system.webServer>節點下增加如下節點:
<modules>
<remove name="UrlRoutingModule-4.0" />
<add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="" />
</modules>