Home > Net >  Changing default page in ASP.Net Core 5
Changing default page in ASP.Net Core 5

Time:11-06

Related Topics:

enter image description here

and change Route for TaskSelection page like this:

enter image description here

Now I want to change first landing page of this web project and I don't want to:

  1. Delete index page

  2. Redirect from index page when Get method called

I wrote this code in ConfigureServices:

services.AddMvc().AddRazorPagesOptions(options =>
{
    options.Conventions.AddPageRoute("/Identity/TaskSelecttion", "/Identity/TaskSelecttion");
});

but it returns to index page!!!.

How can I change default landing page from index to TaskSelection page?

Thanks

CodePudding user response:

I changed the options like this:

services.AddMvc().AddRazorPagesOptions(options =>
{
    options.Conventions.AddPageRoute("/Identity/TaskSelection", "");
});

but I got this error:

AmbiguousMatchException: The request matched multiple endpoints. Matches: /Identity/TaskSelection /Index

so I change the routing for index page like this:

enter image description here

and it worked

  • Related