Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I wanted to set my starting page to /Members/Index.

When I was using MVC, I configured it as following:

app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Members}/{action=Index}/{id?}");
            });

But now I'm trying new Razor Pages approach, and now Members is folder and Index is Razor Page. How to set this page in folder as starting one?

I can add Index page in root directory and make redirect there, but I was looking for something cleaner.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.0k views
Welcome To Ask or Share your Answers For Others

1 Answer

Add the following to your ConfigurationServices function in Startup.cs

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

If you have another index page you'll probably need to delete or rename it.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...