我正在尝试部署静态网络速度测试应用程序. IIS 需要表现得像此 Nginx 配置。
一切正常,但我需要发送 200 而不是 405。运行上传测试时。(向静态文件发出 POST 请求)
寻找类似 Nginx “error_page 405 =200” 的 ISS 等效项
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".webmanifest" mimeType="application/manifest+json" />
<mimeMap fileExtension="." mimeType="application/octet-stream" />
</staticContent>
<urlCompression doStaticCompression="false" />
<httpProtocol>
<customHeaders>
<add name="Cache-Control" value="no-store, no-cache, no-transform, must-revalidate" />
</customHeaders>
</httpProtocol>
<caching enabled="false" enableKernelCache="false" />
<security>
<requestFiltering>
<verbs>
<add verb="POST" allowed="true" />
<add verb="GET" allowed="true" />
</verbs>
<fileExtensions>
<add fileExtension="." allowed="true" />
</fileExtensions>
<alwaysAllowedUrls>
</alwaysAllowedUrls>
<requestLimits maxAllowedContentLength="2147483647"/>
</requestFiltering>
</security>
</system.webServer>
</configuration>
答案1
您可以尝试使用重写规则。请确保match url
根据需要更改指令:
<rewrite>
<rules>
<rule name="customResponseCode">
<match url=".*" />
<action type="CustomResponse" statusCode="200" />
</rule>
</rules>
</rewrite>