Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个需要访问该Server属性的 WebActivator 引导程序。具体来说,它需要知道是什么Server.MapPath("~")。
Server
Server.MapPath("~")
有没有办法做到这一点?
最好的方法是调用HttpRuntime.AppDomainAppPath.
HttpRuntime.AppDomainAppPath
或者,如果您想在任意路径上调用 MapPath,请使用System.Web.Hosting.HostingEnvironment.MapPath("~/some/file.aspx").
System.Web.Hosting.HostingEnvironment.MapPath("~/some/file.aspx")