I am facing a strange issue that I cannot find information on anywhere that matches my specific problem. Some background information:
We are running an ASP.Net site through IIS, connecting to and MSSQL 2012 server on an Azure VM.
So, the issue is that for one specific user our password change page is throwing a server error because Membership.GetUser() is returning a null. We are using the string override to pass the user's username to it.
I have already verified that the string being passed is correct, that the user does exist in our aspnet_Users table, that there is also a aspnet_Membership record for that user's UserID, and that when I am on our password reset page that I am an authenticated
user.
While on this page and debugging the VB code behind in Visual Studio I can call Membership.GetUser() directly and pass through any number of other users and their user information is returned in the Watch window but when I try to do this with the user who
we are facing this issue with the function returns Nothing instead of a Membership object.
We don't know where to go from here because the user exists in the right places in the database and the page works for other usernames, just not this one.
Please let me know if you need any code or any other information.
I was able to solve this on my own. The problem was caused by a really weird issue in the database. At some point, somehow the user's ID was changed to a second account that was created for him in the membership table. Not sure why this was causing the
function to return a null as the username was correct and the linkage to the membership record was also there but when I set it back to his previous account the function returned his user membership record correctly and the password reset page did not crash.
If someone can explain why this happened, I will mark it as the answer.
You can use SQL Server Profiler to trace at which point "the user's ID was changed to a second account that was created for him in the membership table" , which may help you find out the reason and prevent the behavior :
None
0 Points
2 Posts
Membership.GetUser() does not work for a specific user
Sep 06, 2018 08:23 PM|Geowil|LINK
Hello,
I am facing a strange issue that I cannot find information on anywhere that matches my specific problem. Some background information:
We are running an ASP.Net site through IIS, connecting to and MSSQL 2012 server on an Azure VM.
So, the issue is that for one specific user our password change page is throwing a server error because Membership.GetUser() is returning a null. We are using the string override to pass the user's username to it.
I have already verified that the string being passed is correct, that the user does exist in our aspnet_Users table, that there is also a aspnet_Membership record for that user's UserID, and that when I am on our password reset page that I am an authenticated user.
While on this page and debugging the VB code behind in Visual Studio I can call Membership.GetUser() directly and pass through any number of other users and their user information is returned in the Watch window but when I try to do this with the user who we are facing this issue with the function returns Nothing instead of a Membership object.
We don't know where to go from here because the user exists in the right places in the database and the page works for other usernames, just not this one.
Please let me know if you need any code or any other information.
Thanks.
None
0 Points
2 Posts
Re: Membership.GetUser() does not work for a specific user
Sep 06, 2018 09:27 PM|Geowil|LINK
I was able to solve this on my own. The problem was caused by a really weird issue in the database. At some point, somehow the user's ID was changed to a second account that was created for him in the membership table. Not sure why this was causing the function to return a null as the username was correct and the linkage to the membership record was also there but when I set it back to his previous account the function returned his user membership record correctly and the password reset page did not crash.
If someone can explain why this happened, I will mark it as the answer.
All-Star
18815 Points
3831 Posts
Re: Membership.GetUser() does not work for a specific user
Sep 19, 2018 06:54 AM|Nan Yu|LINK
Hi Geowil ,
You can use SQL Server Profiler to trace at which point "the user's ID was changed to a second account that was created for him in the membership table" , which may help you find out the reason and prevent the behavior :
https://docs.microsoft.com/en-us/sql/tools/sql-server-profiler/sql-server-profiler?view=sql-server-2017
Best Regards,
Nan Yu