I am trying to load Login Page in the first start when application is load. So far What I try
Configure
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
//pattern: "{area=Manager}/{controller=Ticket}/{action=Index}/{id?}");
pattern: "{area=Manager}/{controller=Home}/{action=Index}/{id?}");
endpoints.MapRazorPages();
});
ConfigureServices
services.AddMvc().AddRazorPagesOptions(options => {
options.Conventions.AddAreaPageRoute("Identity", "/Account/Login", "");
}).SetCompatibilityVersion(CompatibilityVersion.Version_3_0);
This method works fine, but after user click Login button nothing happened. The Login Page in againg loaded. SO far I check couple of post here but whatever I check it is releted to .NET CORE 2.0
and CORE 2.1
Any idea what is the problem here ?
Default Routes are supposed to redirect people to a common page (like index.* or start.*, etc.) where the user is able to navigate from and do their stuff.
Setting up a login page for that seems wrong to me, because you are not able to do anything else there, but to login and authenticate.
You stated, that you want to always show the login page before anything else happens, then I guess your application is totally secured and no action or function is available without a valid login.
If this is the case, then simply require an Authorization on every single page, that redirects you then automatically to your login screen. You can use [Authorize] attribute for that or even configure it globally inside the Configure method: endpoints.MapRazorPages().RequireAuthorization();
hint: haven't checked this if it works, some searches against "asp.net mvc global authorization" might help here
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments