I am beginner in ASP .NET Core 2.1 and working on project which is using ASP .NET Core 2.1 with individual authentication. I want to make my login page as my default route instead of Home/Index:
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
Any help how can i change it as ASP .NET Core 2.1 as Login is now used as a razor page instead of MVC Action View.
Right click your web project -> Select Properties -> Select the Debug tab on the left -> Then edit the 'Launch Url' field to set your own default launch url.
Select Admin Tools --> IIS Manager --> Select your website from the list. Click on Default Document on the right hand side and Click Add . Move the entry to the top of the list using the arrows. You are done.
UseEndpoints(endpoints => { endpoints. MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); }); Inside the call to UseEndpoints() , we use the MapControllerRoute() method to create a route by giving the name default .
For Asp.Net Core 2.2 right click on Project → Properties → Debug and next to Launch Browser checkbox set path to the startup page you want.
Use this in ConfigureServices method.
services.AddMvc().AddRazorPagesOptions(options=> {
options.Conventions.AddAreaPageRoute("Identity", "/Account/Login","");
}).SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
then in Configure method
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
I solve this by using this code in ConfigureServices
function (Startup.cs)
services.AddMvc().AddRazorPagesOptions(options => {
options.Conventions.AddAreaPageRoute("Identity", "/Account/Login", "/Account/Login");
}).SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
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