User36582938 posted
I am tyring to over come a issue with using session by having a property to store the providerkey i seen examples of this but I am using form authentication so i dont no if i can use that
Guid _UserID;
public Guid UserID
{
get
{
MembershipUser user = Membership.GetUser(HttpContext.Current.User.Identity.Name);
Guid guid;
Debug.Assert(user.ProviderUserKey != null, "user.ProviderUserKey != null");
guid = (Guid)user.ProviderUserKey;
return guid;
}
set
{
this._UserID = value;
}
The erorr I am getting is the following
An exception of type 'System.NullReferenceException' occurred in SkyLarkArenaCms.dll but was not handled in user code
Additional information: Object reference not set to an instance of an object.
I would reference the property via the master page so that all the child pages can use it so then in my child page i just do this for example to get userId
lblCount.Text = _dal.GetUserMessageCount(UserID).ToString();
lblminiCount.Text = lblCount.Text;
Now I have checked the user does have a userID GUID and its not null or blank.
<authentication mode="Forms">
<forms loginUrl="~/BackDoorLogin.aspx"></forms>
</authentication>
What is the best method to handle the userId I have seen the issues with the session and now want to solve it with a 2015 solution allot of the old ways our outdated I am using asp.net webforms and version .net 4.5.2
I have reigsterd my sql tables with aspnetreg_iis so i have my aspnetuser table etc in sql server 2008 r2 thanks for in advance for your support and help