如何在asp.net中获取应用程序路径?

时间:2022-10-01 20:47:49

how to get the application path ? bin path

如何获取应用程序路径? bin路径

in asp.net

在asp.net中

thank's in advance

提前致谢

6 个解决方案

#1


27  

Gets the ASP.NET application's virtual application root path on the server.

获取ASP.NET应用程序在服务器上的虚拟应用程序根路径。

Request.ApplicationPath;

http://msdn.microsoft.com/en-us/library/system.web.httprequest.applicationpath.aspx

http://msdn.microsoft.com/en-us/library/system.web.httprequest.applicationpath.aspx

ResolveUrl("~/bin");

#2


32  

Server.MapPath("~/bin")

You could also use the HostingEnvironment.ApplicationPhysicalPath property.

您还可以使用HostingEnvironment.ApplicationPhysicalPath属性。

#3


12  

Using the following snippet:

使用以下代码段:

string strPath = HttpContext.Current.Server.MapPath("~/bin");

#4


9  

I needed this at app_start where there's not yet an HttpContext, thus Request and Server are not options.

我在app_start需要这个,那里还没有HttpContext,因此Request和Server不是选项。

This did the trick:

这样就可以了:

System.Web.HttpRuntime.BinDirectory

#5


8  

HttpContext.Current.Server.MapPath("~/bin")

Application.StartupPath + "/bin"

AppDomain.CurrentDomain.BaseDirectory + "/bin"

and many more that described in a blog

以及博客中描述的更多内容

#6


3  

Server.MapPath("~/bin")

You can also use Request.PhysicalApplicationPath

您还可以使用Request.PhysicalApplicationPath

#1


27  

Gets the ASP.NET application's virtual application root path on the server.

获取ASP.NET应用程序在服务器上的虚拟应用程序根路径。

Request.ApplicationPath;

http://msdn.microsoft.com/en-us/library/system.web.httprequest.applicationpath.aspx

http://msdn.microsoft.com/en-us/library/system.web.httprequest.applicationpath.aspx

ResolveUrl("~/bin");

#2


32  

Server.MapPath("~/bin")

You could also use the HostingEnvironment.ApplicationPhysicalPath property.

您还可以使用HostingEnvironment.ApplicationPhysicalPath属性。

#3


12  

Using the following snippet:

使用以下代码段:

string strPath = HttpContext.Current.Server.MapPath("~/bin");

#4


9  

I needed this at app_start where there's not yet an HttpContext, thus Request and Server are not options.

我在app_start需要这个,那里还没有HttpContext,因此Request和Server不是选项。

This did the trick:

这样就可以了:

System.Web.HttpRuntime.BinDirectory

#5


8  

HttpContext.Current.Server.MapPath("~/bin")

Application.StartupPath + "/bin"

AppDomain.CurrentDomain.BaseDirectory + "/bin"

and many more that described in a blog

以及博客中描述的更多内容

#6


3  

Server.MapPath("~/bin")

You can also use Request.PhysicalApplicationPath

您还可以使用Request.PhysicalApplicationPath