how can I set a specific page as a default page in .net core 2 using visual studio code

Hi, I'm using visual studio code to develop a web site using core 2. when I debug the project the default page is set as : https://localhost:xxxx

I want to set my page : "Account/Login" as my website's default page .

means when I debug the project the first screen should appear will this : https://localhost:xxxx/Account/Login

how can I do that?


Asked by:- LuneAgile
: 108 At:- 12/6/2018 12:25:12 PM
ASP.NET set-starting-page-in-net-core

2 Answers
profileImage Answered by:- vikas_jk

Within that AddRazorPagesOptions() method, we can set things like route conventions and the root directory for pages. It turns out that, to set a default route for a page, you execute this call

public void ConfigureServices(IServiceCollection services)
    services.AddMvc().AddRazorPagesOptions(options =>
        options.Conventions.AddPageRoute("/Account/Login", "");

Check the Detailed post here

OR set default route in Startup.cs (

   public IConfigurationRoot Configuration { get; }

    public void ConfigureServices(IServiceCollection services)
        // Add framework services.

    public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        //some code here
        //add routing here
        app.UseMvc(routes =>
            //default route
                name: "default",
                template: "{controller=Home}/{action=Index}/{id?}");

In the above code we are adding a default route.

At:- 12/6/2018 4:21:08 PM

profileImage Answered by:- LuneAgile

Thanks so much  vikas_jk.

At:- 12/6/2018 7:28:36 PM

Login/Register to answer
Register directly by posting answer/details

Full Name *

Email *

By posting your answer you agree on privacy policy & terms of use