Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

getting IHostingEnvironment in a static class 1.0

$
0
0

is there a way to get IHostingEnvironment in a static class? you cannot dependency inject into a static class or even in an extension method. so i want to know how to obtain the correct application base path within this situation.

i cannot use PlatformServices.Default.Application.ApplicationBasePath as this does not return the basePath for the application in order for me to map some of the views etc, it returns the runtime bin folder.

originally in RC1 you could use: CallContextServiceLocator.Locator.ServiceProvider.GetRequiredService to obtain the service you required, but i do not know how i do this in 1.0


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>