I am changing Default Page from /Home/Index to /Identity/Account/Login using ASP.NET Core Razor Page but it is always loading /Home page as default page.
services.AddMvc()
.SetCompatibilityVersion(CompatibilityVersion.Version_2_1)
.AddRazorPagesOptions(options =>
{
options.Conventions.Clear();
options.AllowAreas = true;
options.Conventions.AddAreaPageRoute("Identity", "/Login", "/Identity/Account/Login");
});
It should load the Login Page Model as default page. Please help me to solve above problem. Waiting for your quick response.
To map your site's root to the /Identity/Account/Login page in ASP.Net Core (v2.1 and above) you can follow these instructions:
Undo the changes you've made in the ConfigureServices() method. (I.e. .AddRazorPagesOptions(...))
Change the @page declaration at the top of the Login.cshtml template file to @page "/"
If you haven't already, delete the Index.cshtml and Index.cs page files.
Step 1 is for cleaning up.
Step 2 is to configure the Login to the root path /. (more info here)
Step 3 is necessary because if the Index page files are not deleted, they will be mapped by convention to the root path and will conflict with the changes in step 2. This will throw a AmbiguousMatchException when you browse to the root path.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With