Using .NET Core 3.1, I developed a MVC app and deployed it on IIS 8.5.
Using the browser, I am able to go to the home page when I visit domain.com/myApp/
but I get a http 500 error when I go domain.com/myApp
. This is working locally. The issue occurs on the deployed server.
Here is the routing I have in Startup.cs
app.UseEndpoints(endpoints =>
{
// localization
endpoints.MapControllerRoute(
name: "LocalizedDefault",
pattern: "{language:language}/{controller}/{action}/{id?}");
endpoints.MapControllerRoute(
name: "default",
pattern: "{*catchall}",
defaults: new { controller = "Home", action = "RedirectToDefaultCulture", language = "en" });
});
I inserted some log statements inside RedirectToDefaultCulture
action method. It seems the home controller is not being hit when there is no / at the end of the URL
I enabled the Developer Exception and it is not showing me an error
I also tried to give default values to LocalizedDefault
route with no luck.
I was successful in loading the home page by going domain.com/myApp/Index
(no forward slash at the end)
Shouldn't the default endpoint catch the route?