0

Related Topics:

Setting a new landing page in ASP.NET Core MVC

Razor Pages Default Page in aspnetcore 2

In simplest way, I create a new Asp.net razor page project and Create a folder named 'Identity' and two Razor pages like this:

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

Arian
  • 12,793
  • 66
  • 176
  • 300
  • What is the url you testing with? – mxmissile Nov 02 '21 at 18:16
  • When you do options.Conventions.AddPageRoute("/Identity/TaskSelection", "x") , localhost:port/x will take you to Identity/TaskSelection.cshtml. You can setup it up like options.Conventions.AddPageRoute("/Identity/TaskSelection", "") so that when you enter localhost:port/ you get Identity/TaskSelection.cshtml as the default page. – Nish26 Nov 02 '21 at 18:20
  • @mxmissile I just run the project and the url is `https://localhost/` – Arian Nov 03 '21 at 04:31

1 Answers1

1

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

Arian
  • 12,793
  • 66
  • 176
  • 300