Created
July 22, 2016 13:40
-
-
Save mikebrind/a6a2a6bdea9ae248da53ba71785edf1c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void ConfigureServices(IServiceCollection services) | |
{ | |
// Add framework services. | |
services.AddMvc(); | |
services.Configure<RazorViewEngineOptions>(opts => | |
opts.FileProviders.Add( | |
new DatabaseFileProvider(Configuration.GetConnectionString("DefaultConnection")) | |
) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Mike,
I saw your loading views from database article and it helped me a lot. However, in my scenario, code snippets are submitted from the client. Thus, I need a reference to the HttpContext in the FileProvider to get the view's content.
e.g.
The problem is that I have to manually create an instance of the file provider in the Startup.cs, but I depend on DI to inject httpContextAccessor and creating the instance myself is not an option.
Do you have any ideas how to inject dependencies which will change per request to the file provider?
Thanks in advance.