asp.net - MVC5 Authentication redirects to Login Page even after login -
i working on mvc5 project, works fine on system it's behaving strange after deployment on server. used owin authentication, works fine first login, after few seconds if refresh page, redirects me login page (this on happens on deployed server).
my code:
public void configureauth(iappbuilder app) { // enable application use cookie store information signed in user app.usecookieauthentication(new cookieauthenticationoptions { authenticationtype = defaultauthenticationtypes.applicationcookie, loginpath = new pathstring("/account/login") }); // use cookie temporarily store information user logging in third party login provider app.useexternalsignincookie(defaultauthenticationtypes.externalcookie);} i used [authorize] on controller.
[authorize] public class homecontroller : controller { public actionresult index() { return view(); } } here's login code:
[httppost] [allowanonymous] [validateantiforgerytoken] public async task<actionresult> login(loginusermodel model, string returnurl) { if (modelstate.isvalid) { var user = await usermanager.findasync(model.username, model.password); if (user != null) { return redirecttolocal(returnurl); } } }
at glance, either cookie not being set correctly or @ all. or modelstate reason not valid , redirect never hit.
check out link :-
http://coding.abel.nu/2014/06/understanding-the-owin-external-authentication-pipeline/
it should configuration of owin middleware.
Comments
Post a Comment