How can i use the server.mappath method in a C# class library class ,which acts as my BusinessLayer for My ASP.NET WEbsite
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
By calling it?
Make sure you add a reference to the System.Web assembly.
You should reference System.Web and call:
Maybe you could abstract this as a dependency and create an IVirtualPathResolver. This way your service classes wouldn't be bound to System.Web and you could create another implementation if you wanted to reuse your logic in a different UI technology.
Use this System.Web.Hosting.HostingEnvironment.MapPath().
Wonder why nobody mentioned it here.
Architecturally, System.web should not be referred in Business Logic Layer (BLL). Employ BLL into the solution structure to follow the separate of concern principle so refer System.Web is a bad practice. BLL should not load/run in Asp.net context. Because of the reason you should consider using of
System.AppDomain.CurrentDomain.BaseDirectory
instead ofSystem.Web.HttpContext.Current.Server.MapPath