c# - FormsAuthentication Login refuses to redirect after setting auth ticket -



c# - FormsAuthentication Login refuses to redirect after setting auth ticket -

so have login page set own cookie , formsauthenticationticket. however, when take redirect user new homepage after logging in, refuses. redirects right login page no reason. don't understand why.

my web.config part of machinekey removed:

<authentication mode="forms"> <forms loginurl="~/login.aspx" defaulturl="~/default.aspx" cookieless="usecookies" name=".aspxformsauth" timeout="50" /> </authentication> <authorization> <allow users="*" /> </authorization> <machinekey decryption="aes" validation="sha1" ........ />

my login click event after entering username/pass , authenticating true:

if (authenticated) { //create form authentication ticket formsauthenticationticket ticket = new formsauthenticationticket(1, username, datetime.now, datetime.now.addminutes(30), false, username, formsauthentication.formscookiepath); string encryptedcookie = formsauthentication.encrypt(ticket); httpcookie cookie = new httpcookie(formsauthentication.formscookiename, encryptedcookie); response.cookies.add(cookie); response.redirect("mainpage.aspx", true); }

masterpage checks create sure pages can accessed:

else if (context.user.identity.isauthenticated) { if (session["uid"] == null) { userclass u = new userclass(); int uid = -1; uid = (int)u.getuseridbyusername(context.user.identity.name); if (uid != -1) { session["uid"] = uid; } } } else if (!context.user.identity.isauthenticated) { // first check if user redirected changepassword if (!request.path.contains("forgotpass.aspx") && !request.path.contains("changepass.aspx") && !request.path.contains("createaccount.aspx") && !request.path.contains("error.aspx") && !request.path.contains("logout")) { if (!request.path.contains("login")) formsauthentication.redirecttologinpage(); } }

commenting out redirecttologinpage() has no effect. trying utilize redirectfromloginpage has no effect. trying utilize <allow users="?" /> has no effect. trying utilize <deny users="?" /> in conjunction has no effect.

edit: cookie set according browser traffic. no redirect coming through. apparently, either cannot redirect after setting cookie or asp.net doesn't know how read instructions.

use in config file

<authorization> <deny users="?" /> <allow users="*" /> </authorization>

c# asp.net forms-authentication

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -