IHostingEnvironment Updates #157
Open
Labels
Milestone
Comments
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
As part of our update to
IHostingEnvironment
we have made the following changes:ApplicationName
,ContentRootPath
andContentRootFileProvider
.Configuration
andMapPath(string virtualPath)
We aim to relocate the information we provided from
IApplicationEnvironment
toIHostingEnvironment
. This means that the fields onIApplicationEnvironment
, specificallyApplicationName
andApplicationBasePath
, will no longer be set. Instead, theApplicationName
will be set on theIHostingEnvironment
, the application base path is stored in theContentRootPath
field and theContentRootFileProvider
is the file provider for the directory set byContentRootPath
. The extension method to configure the content root is also renamed toUseContentRoot(...)
.All code using
IApplicationEnvironment.ApplicationBasePath
should be changed to useIHostingEnvironment.ContentRootPath
.All code using
IApplicationEnvironment.ApplicationName
should be changed to useIHostingEnvironment.ApplicationName
MapPath
should be replaced by looking at the appropriateIFileProvider
calls (see below).For example, previously it would be:
Now, it should be changed to:
Old (hostingEnvironment is
IHostingEnvironment
). The old MapPath method only worked with files inside of the webroot. To get files on the ContentRoot (where the application code and views lived) required more steps.IHostingEnvironment
now has 2IFileProvider
types exposed:Use aspnet/Hosting#651 for further discussions.
The text was updated successfully, but these errors were encountered: