Hi
I have Startup.cs (_DefaultStartup.cs_) in different netstandard2.0 assembly named CoreLib. When I run WebApplication, it instantiates Startup class correctly at runtime but after that, it returns 404 when processing actual HTTP request.
If I move Startup.cs back to WebApplication it works fine.
If I create a new class in WebApplication derived from DefaultStartup.cs and pass it as a startup it works fine. Not sure what is the reason.
Can you please help? I have attached a sample application.
Similar Issue: #5222
Calling UseStartup resets the config value that drives IHostingEnvironment.ApplicationName. You need to re-order your calls to UseStartup and .UseSetting(WebHostDefaults.ApplicationKey, Assembly.GetEntryAssembly().GetName().Name) in APIActivator. You also need to use Assembly.GetName().Name and not Assembly.FullName as the value for ApplicationKey.
@pranavkm Thank you so much, Pranav! Really appreciate your help.
It's working now. 馃憤
Most helpful comment
Calling
UseStartupresets the config value that drivesIHostingEnvironment.ApplicationName. You need to re-order your calls toUseStartupand.UseSetting(WebHostDefaults.ApplicationKey, Assembly.GetEntryAssembly().GetName().Name)inAPIActivator. You also need to useAssembly.GetName().Nameand notAssembly.FullNameas the value forApplicationKey.