html - Redirect after Login MyWSAT -
i've been testing example code here http://mywsat.codeplex.com/
in example have different buttons login either admin
pages or members
page using seperate links
however, i'm trying use single link landing page , after user logs in redirect relevant page using codebehind. landingpage requires login roles can view page set in rules.
landingpage.aspx:
protected void page_load(object sender, eventargs e) { string redirectpath; string pagepath = request.apprelativecurrentexecutionfilepath; if (page.user.isinrole("administrator")) { //admin redirectpath = "~/admin/default.aspx"; if (redirectpath != pagepath) { response.redirect(redirectpath); } } else if (page.user.isinrole("member")) { //members redirectpath = "~/members/default.aspx"; if (redirectpath != pagepath) { response.redirect(redirectpath); } } else if (page.user.isinrole("trial")) { //trial redirectpath = "~/trial/default.aspx"; if (redirectpath != pagepath) { response.redirect(redirectpath); } } else { //non member redirectpath = "~/default.aspx"; if (redirectpath != pagepath) { response.redirect(redirectpath); } } }
the problem page_load event fires straight away , launches login-with-captcha.ascx
after event has fired.
so moved code login form login-with-captcha.ascx.cs
redirect after e.authenticated = true;
redirects login-with-captcha.ascx
in endless loop
login-with-captcha.ascx.cs:
// next, determine if user's username/password valid if (membership.validateuser(loginusername, loginpassword)) { e.authenticated = true; //tried redirecting here based on role! } else //............
how can redirect landing page after user validated? suspect may have postback need help
can try adding following first line within page_load see if helps? prevent endless loop issue if it's being caused triggers postback event, button click.
if (ispostback) return;
Comments
Post a Comment