How to get the physical location of an ASP.NET web application without using HttpContext.Current?

前端 未结 2 1387
天涯浪人
天涯浪人 2020-12-10 17:19

I\'ve found myself having a requirement to configure log4net based on a file relative to the physical location of the running ASP.NET web application. We like to start the l

2条回答
  •  天命终不由人
    2020-12-10 17:41

    As an alternative answer to my own question, I'd like to add that Server.MapPath() works during the Application_Start event as well. The application domain path would then be equal to Server.MapPath("~"), but it's handier for mapping relative paths, removing the burden of concatenation (what MapPath was meant for to begin with).

提交回复
热议问题