New .NET Core 2.1 web (from template) navigates to wrong url

steps to recreate:
created a new project using the following from command line:
web new web DVCore21
opened project in VS2019
on main project, Properties, Debug, switched property “Launch” from IISExpress to IIS.
The App Url below correctly says http://localhost/DVCore21
Hit F5
Chrome browser loads, briefly showing http://localhost/DVCore21, but then switches to http://localhost/metadata, and shows a 404. Manually navigating to http://localhost/DVCore21/metadata works.

I reported this same problem once before in an older version, a fix was needed. That original post is located here.

Behavior is similar, tho the older version was for Classic ASP.NET Framework not .NET Core.

You can specify Config.HandlerFactoryPath to specify the Virtual Path your App is hosted on e.g:

SetConfig(new HostConfig
{
    DefaultRedirectPath = "/metadata",
    HandlerFactoryPath = "DVCore21",
    DebugMode = AppSettings.Get(nameof(HostConfig.DebugMode), false)
});

I’ve added a fix that pre-populates the HandlerFactoryPath with Environment.GetEnvironmentVariable($"ASPNETCORE_APPL_PATH") in the latest v5.7.1 on MyGet.

1 Like