How to change the default controller and action in ASP.NET Core API?

With later version of ASP .Net Core, MVC routing is less prominent than it once was, there is general routing now in place which can handle routing of Web APIs, MVC and SignalR amongst other kinds of routes.

If you are using later versions, and not specifically calling app.UseMvc you can do this with the generalised Endpoints configuration:

app.UseEndpoints(endpoints =>
{
   endpoints.MapControllerRoute("default", "{controller=Account}/{action=login}/{id?}");
  // Create routes for Web API and SignalR here too...
});

Where Account and login are your new default controller and actions. These can be MVC or Web API controller methods.


You can change it in launchSettings.json file in Properties node. There should be field launchUrl which contains default launching url