This solution should help me explain my desire

This commit is contained in:
Tracy Pearson
2020-10-19 12:55:29 -04:00
parent 4e9964435b
commit 92445d4e7a
18 changed files with 280 additions and 71 deletions

View File

@@ -7,6 +7,7 @@ using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using RepositoryLibrary;
namespace WebMVC
{
@@ -19,13 +20,19 @@ namespace WebMVC
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddControllersWithViews();
if (false)
{
services.AddScoped<IRepository, LocalRepository>();
}
else
{
services.AddScoped<IRepository, HostedRepository>();
}
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
@@ -39,7 +46,21 @@ namespace WebMVC
app.UseStaticFiles();
app.UseRouting();
app.Use(async (context, next) =>
{
try
{
await next();
}
catch (Exception ex)
{
// Here I want to log the exception with the StackTrace.
// The StackTrace when local is what I want
// The StackTrace when Hosted is only to the Hosted. I'd
// like to see the StackTrace returned from ApiService.
return;
}
});
app.UseAuthorization();
app.UseEndpoints(endpoints =>