Anonymous access to threads fails


As an anonymous visitor I get an System.NullReferenceException on line 244 (thread.aspx) when I try to open an existing thread
--> Dim CurrentGUID As Guid = Membership.GetUser().ProviderUserKey() throws
Closed Dec 9, 2009 at 5:20 AM by z2bass
fixed in v3 preview


ninjaduke wrote Aug 20, 2007 at 11:03 PM

I'm having the same problem! but it's not only doing that in anonymous access, it's also doing it for every user except administrators.. The only way to view threads is logged in as administrator..

ERROR: Object reference not set to an instance of an object.

---> Dim CurrentGUID As Guid = Membership.GetUser().ProviderUserKey() throws

Ln 270 Col 9 Ch 9

Visual Studio ProfessionalClub Starter Kit 3 beta 1

mnebinger wrote Aug 22, 2007 at 12:05 PM

I don't use the forums, but here is the fix for the anonymous access failing.

replace the lineDim CurrentGUID as Guid = Membership.GetUser().ProviderUserKey() With:Dim CurrentGUID as Guid Try CurrentGUID = Membership.GetUser().ProviderUserKey()Catch Return FalseEnd Try

All this function is trying to do is see if the user viewing the thread is the person that started the thread. So if the user is anonymous, it is safe to return False. The reason it is throwing an exception is that the line is trying to check the current users GUID through the database. If they are anonymous, they will not be in the database so ProviderUserKey is a null reference.

wrote Dec 9, 2009 at 5:20 AM

wrote Feb 14, 2013 at 2:37 AM

wrote May 16, 2013 at 6:46 AM