2015-06-18 35 views
0

我在努力弄清楚這一點 - 我有一個OData V4服務,我使用.Net ODataConventionModelBuilder開發了這個服務。當在「visual studio內」(即localhost:port/service)中運行時,一切正常,但是當我將服務發佈到IIS時,我無法再發出批量請求。

例1:IISExpress下運行,而Visual Studio是運行

GET http://localhost:1234/service/SomeResource - 工作正常訪問的資源,並返回JSON響應

POST http://localhost:1234/service/ $一批 - 工作正常發送批量請求(顯然與身體數據)多的GET

例2:IIS

下託管

GET http://localhost/service/SomeResource - 工作正常訪問的資源,並返回JSON響應

POST http://localhost/service/ $一批 - 失敗,出現HTTP 404未找到 「消息」:「沒有HTTP資源發現,請求URI「http://localhost/service/ $批次匹配」「, ‘MessageDetail。’:‘不提供控制器名稱找到路由匹配請求的URI‘http://localhost/service/ $一批’’

所以我堅持我不明白爲什麼在工作室中運行時路由工作確定/ IISExpress並沒有在適當的IIS下。

回答

0

好吧,似乎這是由於$批處理部分解釋URL的問題。

將此添加到web.config解決了它。

<system.webServer> 
    <handlers> 
     <remove name="ExtensionlessUrlHandler-Integrated-4.0" /> 
     <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode,runtimeVersionv4.0" /> 
    </handlers> 
    </system.webServer>