{"id":229227,"date":"2023-12-25T00:16:25","date_gmt":"2023-12-24T16:16:25","guid":{"rendered":"https:\/\/www.idc.net\/help\/229227\/"},"modified":"2023-12-25T00:16:25","modified_gmt":"2023-12-24T16:16:25","slug":"iis%e5%ae%89%e5%85%a8%e6%95%99%e7%a8%8b%ef%bc%9a%e4%bd%bf%e7%94%a8x-frame-options%e5%a4%b4%e9%83%a8%e9%98%b2%e8%8c%83%e7%82%b9%e5%87%bb%e5%8a%ab%e6%8c%81","status":"publish","type":"post","link":"https:\/\/idc.net\/help\/229227\/","title":{"rendered":"IIS\u5b89\u5168\u6559\u7a0b\uff1a\u4f7f\u7528X-Frame-Options\u5934\u90e8\u9632\u8303\u70b9\u51fb\u52ab\u6301"},"content":{"rendered":"<p><title id=\"iis%e5%ae%89%e5%85%a8%e6%95%99%e7%a8%8b%ef%bc%9a%e4%bd%bf%e7%94%a8x-frame-options%e5%a4%b4%e9%83%a8%e9%98%b2%e8%8c%83%e7%82%b9%e5%87%bb%e5%8a%ab%e6%8c%81-hnBkzuVSlo\">IIS\u5b89\u5168\u6559\u7a0b\uff1a\u4f7f\u7528X-Frame-Options\u5934\u90e8\u9632\u8303\u70b9\u51fb\u52ab\u6301<\/title><\/p>\n<h1 id=\"iis%e5%ae%89%e5%85%a8%e6%95%99%e7%a8%8b%ef%bc%9a%e4%bd%bf%e7%94%a8x-frame-options%e5%a4%b4%e9%83%a8%e9%98%b2%e8%8c%83%e7%82%b9%e5%87%bb%e5%8a%ab%e6%8c%81-hnBkzuVSlo\">IIS\u5b89\u5168\u6559\u7a0b\uff1a\u4f7f\u7528X-Frame-Options\u5934\u90e8\u9632\u8303\u70b9\u51fb\u52ab\u6301<\/h1>\n<p>\u70b9\u51fb\u52ab\u6301\u662f\u4e00\u79cd\u5e38\u89c1\u7684\u7f51\u7edc\u653b\u51fb\u65b9\u5f0f\uff0c\u653b\u51fb\u8005\u901a\u8fc7\u5c06\u6076\u610f\u7f51\u9875\u5d4c\u5165\u5230\u5408\u6cd5\u7f51\u7ad9\u4e2d\uff0c\u8bf1\u4f7f\u7528\u6237\u70b9\u51fb\uff0c\u4ece\u800c\u8fdb\u884c\u5404\u79cd\u6076\u610f\u64cd\u4f5c\u3002\u4e3a\u4e86\u4fdd\u62a4\u7f51\u7ad9\u548c\u7528\u6237\u7684\u5b89\u5168\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528IIS\u7684X-Frame-Options\u5934\u90e8\u6765\u9632\u8303\u70b9\u51fb\u52ab\u6301\u3002<\/p>\n<h2 id=\"%e4%bb%80%e4%b9%88%e6%98%afx-frame-options%e5%a4%b4%e9%83%a8%ef%bc%9f-hnBkzuVSlo\">\u4ec0\u4e48\u662fX-Frame-Options\u5934\u90e8\uff1f<\/h2>\n<p>X-Frame-Options\u5934\u90e8\u662f\u4e00\u79cdHTTP\u54cd\u5e94\u5934\u90e8\uff0c\u7528\u4e8e\u63a7\u5236\u7f51\u9875\u5728\u6d4f\u89c8\u5668\u4e2d\u7684\u663e\u793a\u65b9\u5f0f\u3002\u901a\u8fc7\u8bbe\u7f6eX-Frame-Options\u5934\u90e8\uff0c\u6211\u4eec\u53ef\u4ee5\u9650\u5236\u7f51\u9875\u662f\u5426\u53ef\u4ee5\u88ab\u5d4c\u5165\u5230\u5176\u4ed6\u7f51\u7ad9\u7684<code>&lt;iframe&gt;<\/code>\u6807\u7b7e\u4e2d\u3002<\/p>\n<h2 id=\"%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8x-frame-options%e5%a4%b4%e9%83%a8%e9%98%b2%e8%8c%83%e7%82%b9%e5%87%bb%e5%8a%ab%e6%8c%81%ef%bc%9f-hnBkzuVSlo\">\u5982\u4f55\u4f7f\u7528X-Frame-Options\u5934\u90e8\u9632\u8303\u70b9\u51fb\u52ab\u6301\uff1f<\/h2>\n<p>\u8981\u4f7f\u7528X-Frame-Options\u5934\u90e8\u9632\u8303\u70b9\u51fb\u52ab\u6301\uff0c\u6211\u4eec\u9700\u8981\u5728IIS\u670d\u52a1\u5668\u4e0a\u8fdb\u884c\u76f8\u5e94\u7684\u914d\u7f6e\u3002\u4ee5\u4e0b\u662f\u5177\u4f53\u7684\u6b65\u9aa4\uff1a<\/p>\n<ol>\n<li>\u6253\u5f00IIS\u7ba1\u7406\u5668\uff0c\u9009\u62e9\u8981\u914d\u7f6e\u7684\u7f51\u7ad9\u3002<\/li>\n<li>\u5728\u7f51\u7ad9\u7684\u7279\u6027\u4e2d\uff0c\u627e\u5230HTTP\u54cd\u5e94\u5934\u90e8\u3002<\/li>\n<li>\u6dfb\u52a0\u4e00\u4e2a\u65b0\u7684HTTP\u54cd\u5e94\u5934\u90e8\uff0c\u540d\u79f0\u4e3a<code>X-Frame-Options<\/code>\uff0c\u503c\u4e3a<code>DENY<\/code>\u3002<\/li>\n<\/ol>\n<p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u6211\u4eec\u5c31\u6210\u529f\u5730\u5728\u7f51\u7ad9\u4e2d\u6dfb\u52a0\u4e86X-Frame-Options\u5934\u90e8\uff0c\u5e76\u8bbe\u7f6e\u4e3aDENY\u3002\u8fd9\u6837\u4e00\u6765\uff0c\u6d4f\u89c8\u5668\u5728\u52a0\u8f7d\u7f51\u9875\u65f6\uff0c\u5982\u679c\u53d1\u73b0\u7f51\u9875\u88ab\u5d4c\u5165\u5230<code>&lt;iframe&gt;<\/code>\u6807\u7b7e\u4e2d\uff0c\u5c31\u4f1a\u62d2\u7edd\u663e\u793a\u8be5\u7f51\u9875\u3002<\/p>\n<h2 id=\"%e5%85%b6%e4%bb%96x-frame-options%e5%a4%b4%e9%83%a8%e7%9a%84%e5%8f%96%e5%80%bc-hnBkzuVSlo\">\u5176\u4ed6X-Frame-Options\u5934\u90e8\u7684\u53d6\u503c<\/h2>\n<p>\u9664\u4e86DENY\u4e4b\u5916\uff0cX-Frame-Options\u5934\u90e8\u8fd8\u53ef\u4ee5\u8bbe\u7f6e\u4e3a\u5176\u4ed6\u53d6\u503c\uff0c\u5177\u4f53\u5982\u4e0b\uff1a<\/p>\n<ul>\n<li><code>DENY<\/code>\uff1a\u62d2\u7edd\u7f51\u9875\u88ab\u5d4c\u5165\u5230\u4efb\u4f55<code>&lt;iframe&gt;<\/code>\u6807\u7b7e\u4e2d\u3002<\/li>\n<li><code>SAMEORIGIN<\/code>\uff1a\u53ea\u5141\u8bb8\u7f51\u9875\u88ab\u5d4c\u5165\u5230\u540c\u6e90\u7f51\u7ad9\u7684<code>&lt;iframe&gt;<\/code>\u6807\u7b7e\u4e2d\u3002<\/li>\n<li><code>ALLOW-FROM uri<\/code>\uff1a\u53ea\u5141\u8bb8\u7f51\u9875\u88ab\u5d4c\u5165\u5230\u6307\u5b9aURI\u7684<code>&lt;iframe&gt;<\/code>\u6807\u7b7e\u4e2d\u3002<\/li>\n<\/ul>\n<p>\u6839\u636e\u5b9e\u9645\u9700\u6c42\uff0c\u6211\u4eec\u53ef\u4ee5\u9009\u62e9\u5408\u9002\u7684\u53d6\u503c\u6765\u914d\u7f6eX-Frame-Options\u5934\u90e8\u3002<\/p>\n<h2 id=\"%e7%a4%ba%e4%be%8b%e4%bb%a3%e7%a0%81-hnBkzuVSlo\">\u793a\u4f8b\u4ee3\u7801<\/h2>\n<p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\u4ee3\u7801\uff0c\u6f14\u793a\u5982\u4f55\u5728ASP.NET\u4e2d\u4f7f\u7528C#\u8bbe\u7f6eX-Frame-Options\u5934\u90e8\uff1a<\/p>\n<pre><code>\nprotected void Application_BeginRequest(object sender, EventArgs e)\n{\n    HttpContext.Current.Response.AddHeader(\"X-Frame-Options\", \"DENY\");\n}\n<\/code><\/pre>\n<p>\u901a\u8fc7\u5728\u5e94\u7528\u7a0b\u5e8f\u7684<code>BeginRequest<\/code>\u4e8b\u4ef6\u4e2d\u6dfb\u52a0\u4e0a\u8ff0\u4ee3\u7801\uff0c\u6211\u4eec\u53ef\u4ee5\u5728\u6bcf\u4e2a\u8bf7\u6c42\u4e2d\u90fd\u6dfb\u52a0X-Frame-Options\u5934\u90e8\uff0c\u5e76\u8bbe\u7f6e\u4e3aDENY\u3002<\/p>\n<h2 id=\"%e6%80%bb%e7%bb%93-hnBkzuVSlo\">\u603b\u7ed3<\/h2>\n<p>\u901a\u8fc7\u4f7f\u7528IIS\u7684X-Frame-Options\u5934\u90e8\uff0c\u6211\u4eec\u53ef\u4ee5\u6709\u6548\u5730\u9632\u8303\u70b9\u51fb\u52ab\u6301\u653b\u51fb\u3002\u901a\u8fc7\u8bbe\u7f6e\u5408\u9002\u7684\u53d6\u503c\uff0c\u6211\u4eec\u53ef\u4ee5\u7075\u6d3b\u5730\u63a7\u5236\u7f51\u9875\u662f\u5426\u53ef\u4ee5\u88ab\u5d4c\u5165\u5230\u5176\u4ed6\u7f51\u7ad9\u7684<code>&lt;iframe&gt;<\/code>\u6807\u7b7e\u4e2d\u3002\u4fdd\u62a4\u7f51\u7ad9\u548c\u7528\u6237\u7684\u5b89\u5168\u662f\u6211\u4eec\u7684\u9996\u8981\u4efb\u52a1\uff0c\u5e0c\u671b\u672c\u6559\u7a0b\u5bf9\u60a8\u6709\u6240\u5e2e\u52a9\u3002<\/p>\n<h3 id=\"%e9%a6%99%e6%b8%af%e6%9c%8d%e5%8a%a1%e5%99%a8%e9%a6%96%e9%80%89%e5%90%8e%e6%b5%aa%e4%ba%91-hnBkzuVSlo\">\u9999\u6e2f\u670d\u52a1\u5668\u9996\u9009\u540e\u6d6a\u4e91<\/h3>\n<p>\u540e\u6d6a\u4e91\u662f\u4e00\u5bb6\u4e13\u4e1a\u7684\u4e91\u8ba1\u7b97\u516c\u53f8\uff0c\u63d0\u4f9b\u9ad8\u6027\u80fd\u7684\u9999\u6e2f\u670d\u52a1\u5668\u3002\u4f5c\u4e3a\u9999\u6e2f\u670d\u52a1\u5668\u7684\u9996\u9009\u54c1\u724c\uff0c\u540e\u6d6a\u4e91\u81f4\u529b\u4e8e\u4e3a\u5ba2\u6237\u63d0\u4f9b\u7a33\u5b9a\u53ef\u9760\u7684\u4e91\u8ba1\u7b97\u670d\u52a1\u3002\u5982\u679c\u60a8\u9700\u8981\u9999\u6e2f\u670d\u52a1\u5668\uff0c\u540e\u6d6a\u4e91\u662f\u60a8\u7684\u4e0d\u4e8c\u9009\u62e9\u3002<\/p>\n<p>\u4e86\u89e3\u66f4\u591a\u5173\u4e8e\u540e\u6d6a\u4e91\u7684\u4fe1\u606f\uff0c\u8bf7\u8bbf\u95ee<a href=\"https:\/\/idc.net\">https:\/\/idc.net<\/a>\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>IIS\u5b89\u5168\u6559\u7a0b\uff1a\u4f7f\u7528X-Frame-Options\u5934\u90e8\u9632\u8303\u70b9\u51fb\u52ab\u6301 IIS\u5b89\u5168\u6559\u7a0b\uff1a\u4f7f\u7528X-Frame-Opt [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[40],"tags":[],"class_list":["post-229227","post","type-post","status-publish","format-standard","hentry","category-iis"],"_links":{"self":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/229227","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/comments?post=229227"}],"version-history":[{"count":0,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/229227\/revisions"}],"wp:attachment":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/media?parent=229227"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/categories?post=229227"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/tags?post=229227"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}