asp.net - LoginView Not Updating After User Login -
i'm using asp.net membership in order manage website users. without using specific 'login controls'. actually, applying membership class methods in order create user account , user login. on other hand, there loginview control in site.master responsible 'welcome username' task. problem that, loginview control isn't updated after creating new account or login. have use specific login controls?
----also, have set login button commandname 'login'! ----should set create user button?
i appreciate help...
the following code login:
if (!membership.validateuser(httputility.htmlencode(txtusername.text), httputility.htmlencode(txtpass.text))) { lblresult.text = "invalid user name , password."; lblresult.visible = true; } else { response.redirect("~/default.aspx"); }
and here registration code:
membershipcreatestatus statususer; try { membership.createuser(httputility.htmlencode(txtusername.text), httputility.htmlencode(txtpass.text), httputility.htmlencode(txtemail.text), ddlsexques.selectedvalue != "-1" ? ddlsexques.text : string.empty, txtsecansw.text == string.empty ? string.empty : txtsecansw.text, true, out statususer); txtemail.text = string.empty; txtpass.text = string.empty; txtrepass.text = string.empty; txtsecansw.text = string.empty; txtusername.text = string.empty; ddlsexques.selectedvalue = "-1"; lblrsl.forecolor = color.green; lblrsl.text = "حساب کاربری شما با موفقیت ایجاد شد."; lblrsl.visible = true; } catch (membershipcreateuserexception error) { lblrsl.text = geterrormessage(error.statuscode); lblrsl.visible = true; }
if you're using own login code, you'll need persist user's authentication information, instance adding cookie response. built-in controls automatically.
i'm assuming you're using forms-based authentication. there's reference .net security class forms auth here, details options available you:
http://msdn.microsoft.com/en-us/library/system.web.security.formsauthentication%28v=vs.100%29.aspx
look @ setauthcookie
, redirectfromloginpage
methods in particular.
as far i'm aware, commandname
property distinguishing between button controls in code. you're using own methods handle user creation, don't think need add own control. more here:
http://msdn.microsoft.com/en-us/library/system.web.security.formsauthentication%28v=vs.100%29.aspx
Comments
Post a Comment