add razor runtime compilation for development environment

This commit is contained in:
David Barker
2020-01-24 10:32:54 +08:00
parent c59d7017f8
commit f1265ec3df
2 changed files with 14 additions and 2 deletions
+12
View File
@@ -15,8 +15,10 @@ namespace MongoIdentitySample.Mvc
{ {
public class Startup public class Startup
{ {
private IWebHostEnvironment _env;
public Startup(IWebHostEnvironment env) public Startup(IWebHostEnvironment env)
{ {
_env = env;
var builder = new ConfigurationBuilder() var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath) .SetBasePath(env.ContentRootPath)
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
@@ -44,6 +46,16 @@ namespace MongoIdentitySample.Mvc
.AddSignInManager() .AddSignInManager()
.AddDefaultTokenProviders(); .AddDefaultTokenProviders();
var builder = services.AddRazorPages();
#if DEBUG
if(_env.IsDevelopment())
{
builder.AddRazorRuntimeCompilation();
}
#endif
services.AddMvc(); services.AddMvc();
services.AddApplicationInsightsTelemetry(); services.AddApplicationInsightsTelemetry();
@@ -31,7 +31,7 @@
@RenderBody() @RenderBody()
<hr /> <hr />
<footer> <footer>
<p>&copy; 2016 - IdentitySample</p> <p>&copy; 2020 - IdentitySample</p>
</footer> </footer>
</div> </div>