I need to use Server.MapPath. Since library projects does not have Startup.cs i cannot apply the normal way.
I need to use Server.MapPath. Since library projects does not have Startup.cs i cannot apply the normal way.
First, register HttpcontextAccessor service in Startup.cs,
services.AddHttpContextAccessor();
then in the class,
private static HttpContext _httpContext => new HttpContextAccessor().HttpContext;
private static IWebHostEnvironment _env => (IWebHostEnvironment)_httpContext.RequestServices.GetService(typeof(IWebHostEnvironment));
now you can access it in a static class and a static method.
This did the trick for me. If anyone needs.