Added Error Handler middleware and Configure methods based on compilation types
This commit is contained in:
parent
2766b3a4f0
commit
3c7ba368fe
|
|
@ -34,6 +34,13 @@ namespace MusicStore.Controllers
|
||||||
return View(albums);
|
return View(albums);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Can be removed and handled when HandleError filter is implemented
|
||||||
|
//https://github.com/aspnet/Mvc/issues/623
|
||||||
|
public IActionResult Error()
|
||||||
|
{
|
||||||
|
return View("~/Views/Shared/Error.cshtml");
|
||||||
|
}
|
||||||
|
|
||||||
private List<Album> GetTopSellingAlbums(int count)
|
private List<Album> GetTopSellingAlbums(int count)
|
||||||
{
|
{
|
||||||
// Group the order details by album and return
|
// Group the order details by album and return
|
||||||
|
|
|
||||||
|
|
@ -97,12 +97,34 @@ namespace MusicStore
|
||||||
services.AddInstance<IMemoryCache>(new MemoryCache());
|
services.AddInstance<IMemoryCache>(new MemoryCache());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//This method is invoked when KRE_ENV is 'Development' or is not defined
|
||||||
|
//The allowed values are Development,Staging and Production
|
||||||
|
public void ConfigureDevelopment(IApplicationBuilder app)
|
||||||
|
{
|
||||||
|
//Display custom error page in production when error occurs
|
||||||
|
//During development use the ErrorPage middleware to display error information in the browser
|
||||||
|
app.UseErrorPage(ErrorPageOptions.ShowAll);
|
||||||
|
Configure(app);
|
||||||
|
}
|
||||||
|
|
||||||
|
//This method is invoked when KRE_ENV is 'Staging'
|
||||||
|
//The allowed values are Development,Staging and Production
|
||||||
|
public void ConfigureStaging(IApplicationBuilder app)
|
||||||
|
{
|
||||||
|
app.UseErrorHandler("/Home/Error");
|
||||||
|
Configure(app);
|
||||||
|
}
|
||||||
|
|
||||||
|
//This method is invoked when KRE_ENV is 'Production'
|
||||||
|
//The allowed values are Development,Staging and Production
|
||||||
|
public void ConfigureProduction(IApplicationBuilder app)
|
||||||
|
{
|
||||||
|
app.UseErrorHandler("/Home/Error");
|
||||||
|
Configure(app);
|
||||||
|
}
|
||||||
|
|
||||||
public void Configure(IApplicationBuilder app)
|
public void Configure(IApplicationBuilder app)
|
||||||
{
|
{
|
||||||
//Error page middleware displays a nice formatted HTML page for any unhandled exceptions in the request pipeline.
|
|
||||||
//Note: ErrorPageOptions.ShowAll to be used only at development time. Not recommended for production.
|
|
||||||
app.UseErrorPage(ErrorPageOptions.ShowAll);
|
|
||||||
|
|
||||||
// Add services from ConfigureServices
|
// Add services from ConfigureServices
|
||||||
app.UsePerRequestServices();
|
app.UsePerRequestServices();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue