IIS 8.5上的HTTP PUT失败

Montane

这似乎比我擅长的更深入IIS!因此,我有一个非常适合GET和POST的Web API控制器。第一个屏幕截图显示了对GET的处理。一切都很棒,我得到了回应。

查看全尺寸 成功细节

但是随后我提出了一个PUT请求,一切都崩溃了。它似乎遍历ManagedPipelineHandler,然后陷入DefaultDocumentModule,并失败,并出现405。

查看全尺寸 失败摘要

查看全尺寸 失败详细信息

没有安装WebDAV,无论如何我都尝试在web.config级别将其删除。处理程序被覆盖以支持PUT。

<handlers>
  <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
  <remove name="OPTIONSVerbHandler" />
  <remove name="TRACEVerbHandler" />
  <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" />
</handlers>

Despite this the request is failing to be handled by ASP.NET and I'm looking for some ideas on debugging? Here is the action method that fails, the PUT and one that works, a GET.

public class ProductsController : ApiController
{
    [HttpPut]
    [Route("api/products")]
    public AddProductResponse AddProduct(AddProductRequest request)
    {
        return new AddProductResponse(); 
    }

    [HttpGet]
    [Route("api/products/manufacturers")]
    public ManufacturersResponse GetProductManufacturers()
    {
        var productService = new ProductService();
        var manufacturers = productService.GetManufacturers();
        return new ManufacturersResponse { Manufacturers = manufacturers.OrderBy(m => m.BusinessName) };
    }
}

Seems I missed the hand off early in the request lifecycle.

FREB seems to show the GENERAL_SHILD_REQUEST_START for the PUT, not sure why the managed pipeline is creating that extra child request that ultimately falls to the DefaultDocumentModule which can't handle a PUT.

Yishai Galatzer

Looked at your scenario (thanks for sharing you repro project), and the issue is that the projected placed the webapi in a /api folder inside the project.

Specifically there was also /api/products, so when the path /api/products was hit for the http put, IIS seen it as a directory browsing request, and refused to serve a PUT verb on it.

解决方案:重命名api文件夹,通常不要尝试在调用REST API的位置正确映射文件夹。在部署中这不是问题,但是在本地Web应用程序上,该文件夹在那里,并且IIS首先处理它。

另一个解决方案(尽管不建议使用)是使用

<modules runAllManagedModulesForAllRequests="true" />

这将使ASP.NET抢先攻破IIS,但是不建议您这样做,只是为了解决类似这样的小问题。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

IIS <8上的ASP.NET 5支持

来自分类Dev

IIS Express 8与IIS

来自分类Dev

如何在Web API应用程序上的IIS 8(Win Server 2012)上启用PUT

来自分类Dev

ReportViewer组件未在IIS 8上呈现

来自分类Dev

在IIS8上安装Django 1.9

来自分类Dev

php文档IIS 8和PHP 7.0.2的HTTP 500错误

来自分类Dev

HTTP错误401.0-未经授权的IIS 8

来自分类Dev

IIs 8将URL从http重定向到https

来自分类Dev

IIS8 HTTP到https重定向陷入循环

来自分类Dev

IIS 8-HTTP错误503。服务不可用

来自分类Dev

无法在Windows Server 2012 / IIS8上安装IIRF

来自分类Dev

IIS 8上的内部服务器错误500

来自分类Dev

通过SNI选项以编程方式在IIS 8上添加绑定

来自分类Dev

ASP.NET vNext,在Azure上启用对IIS 8的压缩?

来自分类Dev

IIS 8上的Blazor WebAssembly-0x8007000d

来自分类Dev

Windows Server 2012上的IIS 8错误权限不足

来自分类Dev

使MVC / cshtml / vbhtml页面在IIS8上运行

来自分类Dev

ASP.NET vNext,在Azure上启用对IIS 8的压缩?

来自分类Dev

无法在Windows Server 2012 / IIS8上安装IIRF

来自分类Dev

在IIS 8上为MVC站点设置默认路由

来自分类Dev

IIS 8 giving an error

来自分类Dev

如何获取PUT和DELETE动词以在IIS上使用WebAPI

来自分类Dev

更改模式时,IIS上的URL重写总是失败

来自分类Dev

IIS 8中的.Net Core和Windows身份验证失败

来自分类Dev

步骤在Web API asp.net 5网站上的IIS 8上启用Windows身份验证

来自分类Dev

可以在localhost上查看IIS8网站,但不能在127.0.0.1上查看

来自分类Dev

Windows 7/8在SSD上安装失败

来自分类Dev

Laravel Homestead:在Windows 8上置备失败

来自分类Dev

在Debian 8上安装MySQL 5.7失败