c# - How does an MVC app know where to redirect the user when using the [Authorize] attribute? -
if setup mvc app authentication , use [authorize]
tag, automatically redirect unauthenticated users login view.
but how know page is login page? i've looked through example app, couldn't find obvious.
edit
i forgot mention i'm using mvc6.
depending on template used create app, if in app_start
folder, there file called startup.auth.cs
. code in there sets authentication. code default mvc template:
app.usecookieauthentication(new cookieauthenticationoptions { authenticationtype = defaultauthenticationtypes.applicationcookie, loginpath = new pathstring("/account/login"), provider = new cookieauthenticationprovider { // enables application validate security stamp when user logs in. // security feature used when change password or add //external login account. onvalidateidentity = securitystampvalidator .onvalidateidentity<applicationusermanager, applicationuser>( validateinterval: timespan.fromminutes(30), regenerateidentity: (manager, user) => user .generateuseridentityasync(manager)) } });
Comments
Post a Comment