in my asp.net web forms app on master page's page load event I call a method "GetCurrentUserFullName()" to retrieve current logged in user's full name and display on top of the page. When every page that uses this master page is loaded,
the master page method GetCurrentUserFullName() is called again. This is rather expensive and I'd like a way to persist the current user's full name after it's retrieved once.
what's the best solution for this situation? session? viewstate? or anything else?
The best method is to create a session variable in which to store the username and to check if the value is null, so only on the first load you will get the username. You could read more at
how to use session state in ASP.NET.
ssfftt
Member
2 Points
14 Posts
persist username
Jan 05, 2013 02:01 PM|LINK
hi
in my asp.net web forms app on master page's page load event I call a method "GetCurrentUserFullName()" to retrieve current logged in user's full name and display on top of the page. When every page that uses this master page is loaded, the master page method GetCurrentUserFullName() is called again. This is rather expensive and I'd like a way to persist the current user's full name after it's retrieved once.
what's the best solution for this situation? session? viewstate? or anything else?
thanks in advance
HostingASPNe...
All-Star
15866 Points
2974 Posts
Re: persist username
Jan 05, 2013 02:08 PM|LINK
Hello,
The best method is to create a session variable in which to store the username and to check if the value is null, so only on the first load you will get the username. You could read more at how to use session state in ASP.NET.
Regards
Free ASP.NET Examples and source code.
francissvk
Participant
1010 Points
343 Posts
Re: persist username
Jan 05, 2013 03:59 PM|LINK
Hi,
you can achive your requirement by any one of these:
1. Session
2. Query string
3. ViewState.
4. Hidden controls
But in security concern First one (Session) is best. The other 3 can be easily tampered. So go with session variable.
Thanks
Click "…Mark As Answer" if my reply helpful to you..
A2Z DotNet