i need to use session variable to catch hold of username in my website? i am using a ASP:Login ctrl

Posted by kallamjreddy-17301 under ASP.NET on 8/8/2012 | Points: 10 | Views : 1118 | Status : [Member] | Replies : 7
Hi ,

When the user logins to my website i need to catch hold of his user name and use it in page load of my master page which i am redirecting it to after login.Here i am using ASP:Login control and ASP configuration tool to set the authentication,roles etc.




Responses

Posted by: Gopesh9 on: 8/9/2012 [Member] Starter | Points: 25

Up
0
Down
You can use the following code in the page load.

if(Membership.ValidateUser(Login.UserName,Login.Password))

{
Session["username"] = Login.UserName;
}


Now using, Label.Text = Session["username"].ToString(); can be written in master page to show the name of the user.

G. S.
.Net Developer

kallamjreddy-17301, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: kallamjreddy-17301 on: 8/9/2012 [Member] Starter | Points: 25

Up
0
Down
Hi Gopesh,

Thanks a Lot, but for Membership class i have added System.Web.Security but i am unable to use Login.Username,Login.Password in this context should i add any Assemblies for this also..

Waiting for your reply.....

Thanks in Advance.
Janardhan reddy

kallamjreddy-17301, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Gopesh9 on: 8/9/2012 [Member] Starter | Points: 25

Up
0
Down
Just try like this

Membership.ValidateUser(Login1.UserName, Login1.Password);


where Login1 is the id of the Login form.

G. S.
.Net Developer

kallamjreddy-17301, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: kallamjreddy-17301 on: 8/9/2012 [Member] Starter | Points: 25

Up
0
Down
I am Getting Null Values login1.UserName=" ",login1.Password=" " shall i use some other event like logginIn,LoggedIn ......

Thanks In advance.

kallamjreddy-17301, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: kallamjreddy-17301 on: 8/9/2012 [Member] Starter | Points: 25

Up
0
Down
Hi Gopesh,

I got the value in LoggingIn event of Login Control.

Thank You,
Janardhan

kallamjreddy-17301, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Gopesh9 on: 8/9/2012 [Member] Starter | Points: 25

Up
0
Down
May be it cannot take the values from the Configuration tool,just check is the Authentication mode in web.config is Forms like

<system.web>

<!-- mode=[Windows|Forms|Passport|None] -->
<authentication mode="Forms" />
</system.web>


G. S.
.Net Developer

kallamjreddy-17301, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Gopesh9 on: 8/9/2012 [Member] Starter | Points: 25

Up
0
Down
Thats good..

G. S.
.Net Developer

kallamjreddy-17301, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response