【问题标题】:OData $batch endpoint not found when hosted in IIS在 IIS 中托管时未找到 OData $batch 端点
【发布时间】:2015-06-18 10:57:07
【问题描述】:

我正在努力解决这个问题 - 我有一个使用 .Net ODataConventionModelBuilder 开发的 OData V4 服务。在“在 Visual Studio 中”运行时一切正常(即 localhost:port/service),但是当我将服务发布到 IIS 时,我无法再发出批处理请求。

Example1 : 在运行 Visual Studio 时在 IISExpress 下运行

获取http://localhost:1234/service/SomeResource - 可以正常访问资源并返回 JSON 响应

发布http://localhost:1234/service/$batch - 可以很好地为多个 GET 发送批处理请求(显然带有正文数据)

示例 2:在 IIS 下托管

获取http://localhost/service/SomeResource - 可以正常访问资源并返回 JSON 响应

POST http://localhost/service/$batch - 失败并出现 HTTP 404 Not Found "Message": "没有找到与请求 URI 'http://localhost/service/$batch' 匹配的 HTTP 资源。", "MessageDetail": "没有找到提供控制器名称的路由来匹配请求 URI 'http://localhost/service/$batch'"

所以我被卡住了,我不明白为什么在 studio/IISExpress 下运行而不是在正确的 IIS 下运行时路由工作正常。

【问题讨论】:

    标签: iis-7.5 odata


    【解决方案1】:

    好吧,这似乎是由于 $batch 部分导致的 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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-08-24
      • 1970-01-01
      • 2014-06-29
      • 1970-01-01
      • 1970-01-01
      • 2016-01-22
      • 1970-01-01
      相关资源
      最近更新 更多