405 错误 IIS8.0 POST 方法不允许
Posted
技术标签:
【中文标题】405 错误 IIS8.0 POST 方法不允许【英文标题】:405 error IIS8.0 POST method not allowed 【发布时间】:2013-12-05 19:30:54 【问题描述】:我有一个运行 IIS8.0 的 Azure 云应用。 我有一个正在运行的 Wordpress 网站,我想向某个资源发出 POST 请求。 当我使用 REST 控制台时,它会使用 200 个代码成功。 当我使用 ios 应用程序时,它会返回 405 错误,并显示“不允许使用方法 POST”的消息。
我检查了请求标头,它们完全一样。
我用谷歌搜索,发现它可能与 IIS 中的处理程序有关,因此这里是我的处理程序:
<handlers accessPolicy="Read, Script">
<add name="php54_via_FastCGI" path="*.php" verb="GET,HEAD,POST" modules="FastCgiModule" scriptProcessor="C:\Program Files (x86)\PHP\v5.4\php-cgi.exe" resourceType="Either" />
<add name="PHP53_via_FastCGI" path="*.php" verb="GET,HEAD,POST" modules="FastCgiModule" scriptProcessor="C:\Program Files (x86)\PHP\v5.3\php-cgi.exe" resourceType="Either" />
<add name="CGI-exe" path="*.exe" verb="*" modules="CgiModule" resourceType="File" requireAccess="Execute" allowPathInfo="true" />
<add name="TRACEVerbHandler" path="*" verb="TRACE" modules="ProtocolSupportModule" requireAccess="None" />
<add name="OPTIONSVerbHandler" path="*" verb="OPTIONS" modules="ProtocolSupportModule" requireAccess="None" />
<add name="StaticFile" path="*" verb="*" modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule" resourceType="Either" requireAccess="Read" />
</handlers>
谁能帮我解决我的问题?
【问题讨论】:
【参考方案1】:您可以尝试使用像 Wireshark 这样的网络数据包侦听器来查看 iOS 发送的原始 HTTP。
【讨论】:
【参考方案2】:我发现了导致问题的原因。 我想知道为什么从我的浏览器发送请求是有效的,而从 iOS 应用程序发送的却不是。
浏览器和应用都发送完全相同的标头、有效负载和 url。
网址是这样的:http://www.example.com/?json=subscribe/subscribe。
原来该应用无法使用此 URL。我不得不使用:http://www.example.com/index.php?json=subscribe/subscribe
必须添加 index.php
才能使 iOS 工作。
我正在将 Wordpress 添加到关键字中。
【讨论】:
以上是关于405 错误 IIS8.0 POST 方法不允许的主要内容,如果未能解决你的问题,请参考以下文章
带有ajax jQuery的405(不允许方法)(POST)方法
自定义 Web api 上的 POST 405(不允许的方法)