{"id":2874,"date":"2025-10-12T13:32:23","date_gmt":"2025-10-12T05:32:23","guid":{"rendered":"https:\/\/www.xfan.top\/?p=2874"},"modified":"2025-10-12T13:32:23","modified_gmt":"2025-10-12T05:32:23","slug":"asp-net%e4%b8%ad%e7%bd%91%e7%ab%99%e6%a0%b9%e7%9b%ae%e5%bd%95%e7%9a%84%e8%8e%b7%e5%8f%96%e6%96%b9%e6%b3%95%e5%af%b9%e6%af%94","status":"publish","type":"post","link":"https:\/\/www.xfan.top\/index.php\/2025\/10\/12\/2874\/","title":{"rendered":"ASP.NET\u4e2d\u7f51\u7ad9\u6839\u76ee\u5f55\u7684\u83b7\u53d6\u65b9\u6cd5\u5bf9\u6bd4"},"content":{"rendered":"<p>\u4f8b\u5982\u83b7\u53d6\u7f51\u7ad9\u6839\u76ee\u5f55\u4e0b\u7684<code>.\/log\/<\/code>\u76ee\u5f55\uff0c\u53ef\u4f7f\u7528\u4e00\u4e0b\u4e09\u79cd\u65b9\u6cd5\uff1a<\/p>\n<pre><code>string Target_Path = System.Web.HttpContext.Current.Server.MapPath(&quot;~\/log\/&quot;);\nstring Target_Path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, &quot;log&quot;);\nstring Target_Path = System.Web.Hosting.HostingEnvironment.MapPath(&quot;~\/log\/&quot;);<\/code><\/pre>\n<p>\u4f9d\u8d56<code>System.Web.HttpContext<\/code>\u4f1a\u5bfc\u81f4\u5728\u6ca1\u6709<code>HttpContext<\/code>\u7684\u7ebf\u7a0b\u4e2d\u62a5\u9519\uff0c\u4f8b\u5982\u5728Global\u6216\u5f02\u6b65\u4efb\u52a1\u4e2d\u3002<br \/>\n\u5bf9\u4e8e\u63a7\u5236\u53f0\u7a0b\u5e8f\u6765\u8bf4\uff0c<code>AppDomain.CurrentDomain.BaseDirectory<\/code>\u6307\u7684\u662f\u7a0b\u5e8f\u8fd0\u884c\u76ee\u5f55\uff0c\u800c\u5bf9\u4e8e<code>ASP.NET<\/code>\u9879\u76ee\u6765\u8bf4\uff0c<code>AppDomain.CurrentDomain.BaseDirectory<\/code>\u4f1a\u88ab\u81ea\u52a8\u6539\u4e3a\u7f51\u7ad9\u6839\u76ee\u5f55\uff0c\u800c\u975e<code>.\/bin\/<\/code>\u76ee\u5f55\uff0c\u6240\u4ee5\uff0c\u5b83\u4e5f\u53ef\u4ee5\u7528\u6765\u83b7\u53d6\u7f51\u7ad9\u6839\u76ee\u5f55\u3002<br \/>\n\u7b2c\u4e09\u79cd\u662f\u4e0d\u4f9d\u8d56<code>HttpContext<\/code>\u7684\uff0c\u4f5c\u7528\u548c\u7b2c\u4e00\u79cd\u4e00\u6837\uff0c\u9002\u5408\u5728\u540e\u53f0\u4efb\u52a1\u3001\u5f02\u6b65\u4efb\u52a1\u4e2d\u4f7f\u7528\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f8b\u5982\u83b7\u53d6\u7f51\u7ad9\u6839\u76ee\u5f55\u4e0b\u7684.\/log\/\u76ee\u5f55\uff0c\u53ef\u4f7f\u7528\u4e00\u4e0b\u4e09\u79cd\u65b9\u6cd5\uff1a string Target_Path = Sys [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2874","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.xfan.top\/index.php\/wp-json\/wp\/v2\/posts\/2874","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xfan.top\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xfan.top\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xfan.top\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xfan.top\/index.php\/wp-json\/wp\/v2\/comments?post=2874"}],"version-history":[{"count":1,"href":"https:\/\/www.xfan.top\/index.php\/wp-json\/wp\/v2\/posts\/2874\/revisions"}],"predecessor-version":[{"id":2875,"href":"https:\/\/www.xfan.top\/index.php\/wp-json\/wp\/v2\/posts\/2874\/revisions\/2875"}],"wp:attachment":[{"href":"https:\/\/www.xfan.top\/index.php\/wp-json\/wp\/v2\/media?parent=2874"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xfan.top\/index.php\/wp-json\/wp\/v2\/categories?post=2874"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xfan.top\/index.php\/wp-json\/wp\/v2\/tags?post=2874"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}