Dar*_*rov 37
Server.MapPath("~/bin")
Run Code Online (Sandbox Code Playgroud)
您还可以使用HostingEnvironment.ApplicationPhysicalPath属性.
hun*_*ter 30
获取ASP.NET应用程序在服务器上的虚拟应用程序根路径.
Request.ApplicationPath;
Run Code Online (Sandbox Code Playgroud)
http://msdn.microsoft.com/en-us/library/system.web.httprequest.applicationpath.aspx
ResolveUrl("~/bin");
Run Code Online (Sandbox Code Playgroud)
jen*_*ent 16
我需要在这app_start
那里是没有的HttpContext
,因此Request
并Server
没有选择.
这样就可以了:
System.Web.HttpRuntime.BinDirectory
Run Code Online (Sandbox Code Playgroud)
Raj*_*mar 15
HttpContext.Current.Server.MapPath("~/bin") ;
Application.StartupPath + "/bin";
AppDomain.CurrentDomain.BaseDirectory + "/bin";
//Note in Asp.net Core its little bit different
public class ValuesController : ControllerBase
{
IHostingEnvironment _hostingEnvironment;
public ValuesController(IHostingEnvironment hostingEnvironment)
{
_hostingEnvironment = hostingEnvironment;
string applicationPath = _hostingEnvironment.ContentRootPath;
string wwwrootPath = _hostingEnvironment.WebRootPath;
}
}
Run Code Online (Sandbox Code Playgroud)
以及博客中描述的更多内容
Sut*_*rth 13
使用以下代码段:
string strPath = HttpContext.Current.Server.MapPath("~/bin");
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
56254 次 |
最近记录: |