0

I have this link in my Home/Index view:

<a asp-controller="About" asp-action="Index">About Link Test</a>

And this link in my About/Index view:

<a asp-controller="Home" asp-action="Index">Home Link Test</a>

I have a typical default route convention in Startup.cs:

app.UseEndpoints(endpoints =>
{
  endpoints.MapControllerRoute(
  name: "default",
  pattern: "{controller=Home}/{action=Index}/{id?}");
});

When I run the app, I see the Home/Index view as expected. However when I click on the action, I get a 403 Forbidden as it attempts to treat the About route as a directory. The physical path displayed in the error displays is also odd, as it looks like it's trying to list the application root.

Now for the "sometimes" part. If I change my default route in Startup.cs to this:

app.UseEndpoints(endpoints =>
{
  endpoints.MapControllerRoute(
  name: "default",
  pattern: "{controller=About}/{action=Index}/{id?}");
});

Then when I run the app I see the About/Index view as expected. The Home/Index action link works, and oddly so does the About/Index link on the Home/Index view! The same link that broke with a different controller default route.

I'm still fairly new to MVC in ASP.NET Core 3.1, so I'm sure this is a simple configuration issue or something, but I would appreciate any guidance on why the route isn't mapping correctly depending on the default route map!

Andy
  • 12,859
  • 5
  • 41
  • 56
Jason
  • 319
  • 5
  • 15

1 Answers1

0

Actually, weirdly, this turned out to be another symptom of this issue:

HTTP Error 500.35 - ANCM Multiple In-Process Applications in same Process ASP.NET Core 3

I deleted the configuration file specified in the .vs folder, and upon restarting the VS the links worked normally.

Jason
  • 319
  • 5
  • 15