c# - Authentication & Authorization not working properly -
i first time dealing authentication , authorization.
in web.config have following code authentication & authorization:
<authentication mode="forms"> <forms loginurl="authentication.aspx" timeout="30" defaulturl="default.aspx" cookieless="autodetect" > <credentials passwordformat="clear"> <user name="shiv" password="abc@123"/> <user name="raj" password="abc@123"/> </credentials> </forms> </authentication> <authorization> <deny users="?"/> </authorization>
and
<location path="admin.aspx"> <system.web> <authorization> <allow users="shiv"/> <deny users="*"/> </authorization> </system.web> </location> <location path="users.aspx"> <system.web> <authorization> <allow users="shiv"/> <allow users="raj"/> <deny users="*"/> </authorization> </system.web> </location>
.cs code:
protected void btnlogin_click(object sender, eventargs e) { if(formsauthentication.authenticate(txtusername.text,txtpassword.text)) { formsauthentication.redirectfromloginpage(txtusername.text,true); } }
as expectation,when make login 'raj' user, should redirect me users.aspx
, every time redirecting me default.aspx
why working so?
has made wrong?
please me.
in web.config, in authentication/forms
section, change defaulturl
appropriately:
change
defaulturl="default.aspx"
to this:
defaulturl="users.aspx"
about formsauthentication.redirectfromloginpage
redirects authenticated user requested url or default url.
Comments
Post a Comment