Asked by:
Override the MembershipUer default IsOnline property

Question
-
User1909155429 posted
I am attempting to create a new user account using the MembershipUser class from code, after i login to my current account. I am allowed to create another User but the Online property is set to Isonline and is persisted even after i logout of my account.
Is it possible to access this property and reset it to false at creation?
Thursday, December 24, 2020 2:21 PM
All replies
-
User475983607 posted
I am attempting to create a new user account using the MembershipUser class from code, after i login to my current account. I am allowed to create another User but the Online property is set to Isonline and is persisted even after i logout of my account.
Is it possible to access this property and reset it to false at creation?
It really helps to read the documentation.
The IsOnline property is calculated from the last time the user made a request and timeout configuration. This information is covered in the official (and openly published) reference documentation; https://docs.microsoft.com/en-us/dotnet/api/system.web.security.membershipuser.isonline?view=netframework-4.8
Set the LastActivetyDate to where the timeout has expired.
Thursday, December 24, 2020 2:34 PM -
User1909155429 posted
I tried to set the LastActivetyDate to a previous date, directly after creating new user account though it did not affect the IsOnline property?
Not able to verify anything at moment as my computer broke and I require new plus MVSD software. You would not believe but the computer I was using ran slow and fan on continuous. It took me 30 sec a time just to run the page in browser and I operated like that for 3 years with intermittent power supply and detached screen!
Thursday, December 31, 2020 7:28 PM -
User-939850651 posted
Hi peterthegreat,
According to the official document mentioned by mgebhard, a user is considered online if the current date and time minus the UserIsOnlineTimeWindow property value is earlier than the LastActivityDate for the user.
I'm not sure if you use the UpdateUser() method to set the property as in the document example. Or did you use other code to try to implement it?
Best regards,
Xudong Peng
Tuesday, January 5, 2021 8:17 AM -
User1909155429 posted
i had set LastActivityDate using UpdateUser() method without success? i currently dont have access to the code now because i have replaced my computer and require latest developer software.
Thursday, January 21, 2021 3:20 PM -
User475983607 posted
i had set LastActivityDate using UpdateUser() method without success? i currently dont have access to the code now because i have replaced my computer and require latest developer software.
You did not share the code that was not successful or the steps to reproduce the issue. Keep in mind, the documentation linked above states...
The LastActivityDate for a user is updated to the current date and time by the CreateUser, UpdateUser and ValidateUser methods, and can be updated by some of the overloads of the GetUser method.
Perhaps the LastActivetyDate result is not what you expect. Did you verify the date?
Thursday, January 21, 2021 4:13 PM