In Startup.cs Configure function I do something like this:
app.UseStaticFiles(new StaticFileOptions()
{
FileProvider = new PhysicalFileProvider(@"\\server\somepath\someimages"),
RequestPath = "/images"
});
Later, say in the controller, I'd like to not hard-code:
string ImageImLookingFor = "/images" + foo.jpg;
Instead I'd like to do something like:
string ImageImLookingFor = SomeObjectThatGivesMe.RequestPath + foo.jpg;
Is this possible?
Not entirely sure if it is possible but a workaround can be an appsettings key and read it from both locations.
ex: in your appsettings
in Starup.cs
In your contorller
You can make the configuration file a strong type and replace it with
IOptions<ImageConfiguration>
whereImageConfiguration
is a class that hasImagesPath
property