question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Change ASP.NET Core Razor pages Default page

See original GitHub issue

For ASP.NET Core MVC , we could get it easily by changing the route in app.UseMvc().

For Razor pages , MVC routing does not apply since Razor pages uses a different routing setup .But an error is generated when I tried to configure it using the AddRazorPagesOptions extension method to AddMvc like below:

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

What the error is show

AmbiguousActionException: Multiple actions matched. The following actions matched route data and had all constraints satisfied: Page: /App Page: /Index

If I remove or rename “Pages/Index.cshtml” , it worked . But this workaround seems to be not reasonable. I wonder whether there is any other methods to change Razor pages Default page without changing the original one.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
mdpopescucommented, Aug 25, 2019

Sometimes I cannot help but think that MS employees intend to fit the stereotype. (You know the joke with the technically true but useless response.)

The only thing I can see on that page is the “configure a page route” section, which shows the exact example that the OP says is not working. Was it so difficult to explain exactly how to do what’s being asked, instead of pointing to a long and complex page?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Change a default Homepage in ASP.NET Core Razor Pages
Hello, I am creating an ASP.NET Core Razor Pages website, where the planned layout of the website will be the following navigation menu ......
Read more >
Change default page in ASP.NET Core Razor ...
One option is to edit the @page directive in the Index.cshtml and Home.cshtml files to configure the routes: /* Home.cshtml.cs */ @page "/"...
Read more >
Setting a Custom Default Page in ASP.NET Core Razor ...
We can set a custom default landing page for our ASP.NET Core Razor Pages apps! Here's how.
Read more >
Setting A Custom Page As Landing Page In .Net Core ...
In this article, I will provide information on how to set a custom .NET Core Razor Page as your home/landing page.
Read more >
Configuring Default Page in ASP.NET Core
First, give an appropriate name for your project (FirstCoreWebApplication), set the location where you want to create this project, and the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found