I have an ASP.NET Core MVC web application running .NET Core 2.2. I was troubleshooting some issues in my AutoMapper configuration, and I decided to update to the latest NuGet package for AutoMapper (version 8.1.1). After that update, whenever I run the solution (and have known AutoMapper config errors) I receive a blank browser window with a 404 error (This localhost page can’t be found). Previously, I would get the developer exception page listing the AutoMapper config errors.
I have checked my startup.cs file and reviewed these .NET Core docs. I had previously been calling autoMapper.ConfigurationProvider.AssertConfigurationIsValid() before setting up the developer exception page, so I thought that might be the cause, but now I have it like below and, when there is an automapper config error, this method doesn't even get called before the 404 page is displayed. If I fix the automapper config, this method gets called, and the site loads.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, IMemoryCache cache, IMapper autoMapper)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
app.UseHsts();
}
autoMapper.ConfigurationProvider.AssertConfigurationIsValid();
}
One other change I made to try to fix this was in my ConfigureServices method, I changed:
services.AddAutoMapper();
to:
services.AddAutoMapper(typeof(MappingProfile));
As I noticed a warning in Visual Studio regarding calling the AddAutoMapper method with no parameters. This didn't fix the issue either.
What else can I try to resolve this?