I have this in my Startup.cs file:
app.UseMvc(routes =>
{
routes.MapRoute(
name: "list",
template: "{controller=List}/{action=Index}/{username?}");
});
I want this:
/list/
to return a view.
and this:
/list/random_username.12334
to return another view.
I have this in my ListController.cs:
public IActionResult Index(string username)
{
if (String.IsNullOrEmpty(username))
{
ViewData["Message"] = "user index";
} else {
ViewData["Message"] = "Hello " + username;
}
return View();
}
But only the index without parameters work. The other one returns 404.
/Index.