System.AppDomain.CurrentDomain.BaseDirectory和System.Web.HttpContext.Current.Server.MapPath之间有什么区别? [英] what is difference between System.AppDomain.CurrentDomain.BaseDirectory and System.Web.HttpContext.Current.Server.MapPath?
问题描述
System.AppDomain.CurrentDomain.BaseDirectory
这适用于localhost,但在服务器上部署时它不起作用但是当我使用
this works on localhost but when deploy on server it's not working but when I using
System.Web.HttpContext.Current.Server.MapPath
然后工作.. !!
推荐答案
大多数情况下两者都返回相同的值,但它们有一些差别。
Both are return the same value most of case but they have some deference.
System.AppDomain.CurrentDomain.BaseDirectory
获取程序集解析器用于探测程序集的基目录
安全性:用于访问路径本身的信息,包括路径是否在表格file://或\\UNC\dir或c:\
Get the base directory that the assembly resolver uses to probe for assemblies
Security: for access to the information in the path itself, including if the path is in the form "file://" or \\UNC\dir or "c:\"
System.Web.HttpContext.Current.Server.MapPath
返回与Web服务器上指定虚拟路径对应的应用程序的物理路径。
在Visual Studio 2010测试项目中,如果你启用编辑测试设置的部署选项,AppDomain.CurrentDomain.BaseDirectory指向 TestResults\Out文件夹(不是bin \debug)
。虽然,默认设置指向 bin\debug
文件夹。
return the physical path of you application that correspond to the specified virtual path on the web server.
In Visual studio 2010 test projects, if you enable deployment option of Edit test settings, AppDomain.CurrentDomain.BaseDirectory points to the TestResults\Out folder(not bin\debug)
. Although, default setting point to bin\debug
folder.
这篇关于System.AppDomain.CurrentDomain.BaseDirectory和System.Web.HttpContext.Current.Server.MapPath之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!