{"id":47074,"date":"2024-10-07T11:12:13","date_gmt":"2024-10-07T03:12:13","guid":{"rendered":"https:\/\/server.hk\/cnblog\/47074\/"},"modified":"2024-10-07T11:12:13","modified_gmt":"2024-10-07T03:12:13","slug":"iis%e7%8b%80%e6%85%8b%e7%a2%bc-405-method-not-allowed%ef%bc%88%e6%96%b9%e6%b3%95%e4%b8%8d%e8%a2%ab%e5%85%81%e8%a8%b1%ef%bc%89","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/47074\/","title":{"rendered":"IIS\u72c0\u614b\u78bc &#8211; 405 Method Not Allowed\uff08\u65b9\u6cd5\u4e0d\u88ab\u5141\u8a31\uff09"},"content":{"rendered":"<h1 id=\"iis%e7%8b%80%e6%85%8b%e7%a2%bc-405-method-not-allowed%ef%bc%88%e6%96%b9%e6%b3%95%e4%b8%8d%e8%a2%ab%e5%85%81%e8%a8%b1%ef%bc%89-foyGYQPXwM\">IIS\u72c0\u614b\u78bc &#8211; 405 Method Not Allowed\uff08\u65b9\u6cd5\u4e0d\u88ab\u5141\u8a31\uff09<\/h1>\n<p>\u5728\u7db2\u7d61\u61c9\u7528\u7a0b\u5e8f\u7684\u958b\u767c\u548c\u904b\u884c\u4e2d\uff0cHTTP\u72c0\u614b\u78bc\u662f\u7528\u4f86\u6307\u793a\u8acb\u6c42\u7684\u7d50\u679c\u7684\u91cd\u8981\u5de5\u5177\u3002\u9019\u4e9b\u72c0\u614b\u78bc\u5e6b\u52a9\u958b\u767c\u8005\u548c\u7528\u6236\u7406\u89e3\u8acb\u6c42\u7684\u8655\u7406\u60c5\u6cc1\u3002\u5176\u4e2d\uff0c405 Method Not Allowed\uff08\u65b9\u6cd5\u4e0d\u88ab\u5141\u8a31\uff09\u662f\u4e00\u500b\u5e38\u898b\u7684\u72c0\u614b\u78bc\uff0c\u901a\u5e38\u8868\u793a\u5ba2\u6236\u7aef\u6240\u4f7f\u7528\u7684HTTP\u65b9\u6cd5\u4e0d\u88ab\u670d\u52d9\u5668\u6240\u652f\u6301\u3002<\/p>\n<h2 id=\"%e4%bb%80%e9%ba%bc%e6%98%af405%e7%8b%80%e6%85%8b%e7%a2%bc%ef%bc%9f-foyGYQPXwM\">\u4ec0\u9ebc\u662f405\u72c0\u614b\u78bc\uff1f<\/h2>\n<p>\u7576\u5ba2\u6236\u7aef\u5411\u670d\u52d9\u5668\u767c\u9001\u8acb\u6c42\u6642\uff0c\u8acb\u6c42\u4e2d\u5305\u542b\u7684HTTP\u65b9\u6cd5\uff08\u5982GET\u3001POST\u3001PUT\u3001DELETE\u7b49\uff09\u5fc5\u9808\u662f\u670d\u52d9\u5668\u6240\u5141\u8a31\u7684\u3002\u5982\u679c\u5ba2\u6236\u7aef\u4f7f\u7528\u4e86\u4e00\u500b\u670d\u52d9\u5668\u4e0d\u652f\u6301\u7684\u65b9\u6cd5\uff0c\u670d\u52d9\u5668\u5c07\u8fd4\u56de405\u72c0\u614b\u78bc\uff0c\u4e26\u901a\u5e38\u6703\u5728\u97ff\u61c9\u4e2d\u5305\u542b\u4e00\u500bAllow\u6a19\u982d\uff0c\u5217\u51fa\u8a72\u8cc7\u6e90\u6240\u652f\u6301\u7684HTTP\u65b9\u6cd5\u3002<\/p>\n<h2 id=\"405%e7%8b%80%e6%85%8b%e7%a2%bc%e7%9a%84%e5%b8%b8%e8%a6%8b%e5%8e%9f%e5%9b%a0-foyGYQPXwM\">405\u72c0\u614b\u78bc\u7684\u5e38\u898b\u539f\u56e0<\/h2>\n<ul>\n<li><strong>\u4e0d\u6b63\u78ba\u7684HTTP\u65b9\u6cd5\uff1a<\/strong>\u5ba2\u6236\u7aef\u53ef\u80fd\u4f7f\u7528\u4e86\u932f\u8aa4\u7684HTTP\u65b9\u6cd5\u3002\u4f8b\u5982\uff0c\u5c0d\u65bc\u4e00\u500b\u53ea\u5141\u8a31GET\u8acb\u6c42\u7684\u8cc7\u6e90\uff0c\u82e5\u5ba2\u6236\u7aef\u4f7f\u7528POST\u8acb\u6c42\uff0c\u5247\u6703\u8fd4\u56de405\u932f\u8aa4\u3002<\/li>\n<li><strong>\u670d\u52d9\u5668\u914d\u7f6e\u554f\u984c\uff1a<\/strong>\u5728\u67d0\u4e9b\u60c5\u6cc1\u4e0b\uff0c\u670d\u52d9\u5668\u7684\u914d\u7f6e\u53ef\u80fd\u4e0d\u5141\u8a31\u67d0\u4e9bHTTP\u65b9\u6cd5\u3002\u9019\u53ef\u80fd\u662f\u7531\u65bc\u5b89\u5168\u7b56\u7565\u6216\u5176\u4ed6\u914d\u7f6e\u539f\u56e0\u3002<\/li>\n<li><strong>API\u8a2d\u8a08\u4e0d\u7576\uff1a<\/strong>\u5728\u8a2d\u8a08RESTful API\u6642\uff0c\u5982\u679c\u6c92\u6709\u6b63\u78ba\u5b9a\u7fa9\u6bcf\u500b\u7aef\u9ede\u6240\u652f\u6301\u7684HTTP\u65b9\u6cd5\uff0c\u53ef\u80fd\u6703\u5c0e\u81f4405\u932f\u8aa4\u3002<\/li>\n<\/ul>\n<h2 id=\"%e5%a6%82%e4%bd%95%e8%a7%a3%e6%b1%ba405%e9%8c%af%e8%aa%a4-foyGYQPXwM\">\u5982\u4f55\u89e3\u6c7a405\u932f\u8aa4<\/h2>\n<p>\u7576\u9047\u5230405 Method Not Allowed\u932f\u8aa4\u6642\uff0c\u53ef\u4ee5\u63a1\u53d6\u4ee5\u4e0b\u5e7e\u500b\u6b65\u9a5f\u4f86\u89e3\u6c7a\u554f\u984c\uff1a<\/p>\n<ul>\n<li><strong>\u6aa2\u67e5HTTP\u65b9\u6cd5\uff1a<\/strong>\u9996\u5148\uff0c\u78ba\u8a8d\u5ba2\u6236\u7aef\u6240\u4f7f\u7528\u7684HTTP\u65b9\u6cd5\u662f\u5426\u6b63\u78ba\u3002\u53ef\u4ee5\u53c3\u8003API\u6587\u6a94\u6216\u670d\u52d9\u5668\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u78ba\u4fdd\u4f7f\u7528\u7684HTTP\u65b9\u6cd5\u662f\u88ab\u5141\u8a31\u7684\u3002<\/li>\n<li><strong>\u67e5\u770bAllow\u6a19\u982d\uff1a<\/strong>\u7576\u670d\u52d9\u5668\u8fd4\u56de405\u932f\u8aa4\u6642\uff0c\u901a\u5e38\u6703\u5728\u97ff\u61c9\u4e2d\u5305\u542bAllow\u6a19\u982d\u3002\u9019\u500b\u6a19\u982d\u5217\u51fa\u4e86\u8a72\u8cc7\u6e90\u6240\u652f\u6301\u7684HTTP\u65b9\u6cd5\uff0c\u6839\u64da\u9019\u4e9b\u65b9\u6cd5\u9032\u884c\u8abf\u6574\u3002<\/li>\n<li><strong>\u6aa2\u67e5\u670d\u52d9\u5668\u914d\u7f6e\uff1a<\/strong>\u5982\u679c\u4f60\u662f\u670d\u52d9\u5668\u7684\u7ba1\u7406\u54e1\uff0c\u6aa2\u67e5\u670d\u52d9\u5668\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u78ba\u4fdd\u6b63\u78ba\u8a2d\u7f6e\u4e86\u6240\u9700\u7684HTTP\u65b9\u6cd5\u3002\u5c0d\u65bcIIS\u670d\u52d9\u5668\uff0c\u53ef\u4ee5\u5728IIS\u7ba1\u7406\u5668\u4e2d\u6aa2\u67e5\u76f8\u61c9\u7684\u8a2d\u7f6e\u3002<\/li>\n<li><strong>\u8abf\u8a66API\u8a2d\u8a08\uff1a<\/strong>\u5982\u679c\u662fAPI\u7684\u554f\u984c\uff0c\u6aa2\u67e5API\u7684\u8a2d\u8a08\uff0c\u78ba\u4fdd\u6bcf\u500b\u7aef\u9ede\u90fd\u6b63\u78ba\u5b9a\u7fa9\u4e86\u652f\u6301\u7684HTTP\u65b9\u6cd5\u3002<\/li>\n<\/ul>\n<h2 id=\"%e7%af%84%e4%be%8b%e4%bb%a3%e7%a2%bc-foyGYQPXwM\">\u7bc4\u4f8b\u4ee3\u78bc<\/h2>\n<p>\u4ee5\u4e0b\u662f\u4e00\u500b\u7c21\u55ae\u7684\u7bc4\u4f8b\uff0c\u5c55\u793a\u5982\u4f55\u5728Node.js\u4e2d\u8655\u7406405\u932f\u8aa4\uff1a<\/p>\n<pre><code>\nconst express = require('express');\nconst app = express();\n\napp.get('\/example', (req, res) =&gt; {\n    res.send('GET request received');\n});\n\n\/\/ \u53ea\u5141\u8a31GET\u8acb\u6c42\napp.post('\/example', (req, res) =&gt; {\n    res.status(405).send('Method Not Allowed');\n});\n\napp.listen(3000, () =&gt; {\n    console.log('Server is running on port 3000');\n});\n<\/code><\/pre>\n<h2 id=\"%e7%b8%bd%e7%b5%90-foyGYQPXwM\">\u7e3d\u7d50<\/h2>\n<p>405 Method Not Allowed\u72c0\u614b\u78bc\u662fHTTP\u5354\u8b70\u4e2d\u4e00\u500b\u91cd\u8981\u7684\u97ff\u61c9\u78bc\uff0c\u5e6b\u52a9\u958b\u767c\u8005\u8b58\u5225\u8acb\u6c42\u4e2d\u4f7f\u7528\u7684HTTP\u65b9\u6cd5\u662f\u5426\u88ab\u670d\u52d9\u5668\u6240\u652f\u6301\u3002\u901a\u904e\u6aa2\u67e5HTTP\u65b9\u6cd5\u3001Allow\u6a19\u982d\u4ee5\u53ca\u670d\u52d9\u5668\u914d\u7f6e\uff0c\u53ef\u4ee5\u6709\u6548\u5730\u89e3\u6c7a\u6b64\u985e\u932f\u8aa4\u3002\u5728\u9032\u884c\u7db2\u7d61\u61c9\u7528\u958b\u767c\u6642\uff0c\u4e86\u89e3\u548c\u8655\u7406\u9019\u4e9b\u72c0\u614b\u78bc\u662f\u81f3\u95dc\u91cd\u8981\u7684\u3002<\/p>\n<p>\u5982\u679c\u60a8\u9700\u8981\u66f4\u591a\u6709\u95dc<code><a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a><\/code>\u548c<code><a href=\"https:\/\/server.hk\">\u96f2\u4f3a\u670d\u5668<\/a><\/code>\u7684\u8cc7\u8a0a\uff0c\u8acb\u8a2a\u554f\u6211\u5011\u7684\u7db2\u7ad9\u4ee5\u7372\u53d6\u66f4\u591a\u8a73\u7d30\u8cc7\u6599\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e86\u89e3IIS\u72c0\u614b\u78bc405\uff08\u65b9\u6cd5\u4e0d\u88ab\u5141\u8a31\uff09\uff0c\u5176\u539f\u56e0\u53ca\u89e3\u6c7a\u65b9\u6848\uff0c\u5e6b\u52a9\u60a8\u6392\u9664HTTP\u8acb\u6c42\u4e2d\u7684\u554f\u984c\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4924],"tags":[],"class_list":["post-47074","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/47074","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=47074"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/47074\/revisions"}],"predecessor-version":[{"id":47075,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/47074\/revisions\/47075"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=47074"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=47074"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=47074"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}