I cannnot get my ASP .NET Core MVC site to route to different controller other than Home. I changed the default route in Startup
(it is the only route):
app.UseMvc(routes =>
{
routes.MapRoute(name: "default", template: "{controller=profile}/{action=index}/{id?}");
});
my ProfileController
looks like:
public class ProfileController : Controller
{
[HttpGet("index")]
public IActionResult Index()
{
return View();
}
...
}
But all I get is 404 returned form the Kestrel server on navigating to base URL.
I've just created a new project and it worked for me. Maybe you're doing something else wrong.
Here's what I did.
Update the default route in the Startup.cs:
Create the Profile Controller:
Create the Index View for the Profile Controller:
UPDATE:
The problem was the
[HttpGet("index")]
in the Profile Controller.