Hi, I'm using visual studio code to develop a web site using asp.net 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?
Thanks
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 https://exceptionnotfound.net/setting-a-custom-default-page-in-asp-net-core-razor-pages/
OR set default route in Startup.cs (https://andrewlock.net/exploring-program-and-startup-in-asp-net-core-2-preview1-2/)
public IConfigurationRoot Configuration { get; }
public void ConfigureServices(IServiceCollection services)
{
// Add framework services.
services.AddMvc();
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
//some code here
//add routing here
app.UseMvc(routes =>
{
//default route
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
}
In the above code we are adding a default route.
Thanks so much vikas_jk.
Subscribe to our weekly Newsletter & Keep getting latest article/questions in your inbox weekly