0
votes

I am using membership and have created a custom profile that contains a property called FirstName. It works well except when the session/cookies are lost (I haven't figured out exactly which since it's pretty hard to reproduce). Then when I access any page of the site I get this exception:

[SettingsPropertyNotFoundException: The settings property 'FirstName' was not found.] System.Configuration.SettingsBase.GetPropertyValueByName(String propertyName) +8757578 System.Configuration.SettingsBase.get_Item(String propertyName) +118 System.Web.Profile.ProfileBase.GetInternal(String propertyName) +49 System.Web.Profile.ProfileBase.get_Item(String propertyName) +129 WebFrontend.Security.SecurityHandler.get_FullName() +168 WebFrontend.Controls.LoginInfo.SetupLoginStatus() +15 System.Web.UI.Control.InitRecursive(Control namingContainer) +186 System.Web.UI.Control.InitRecursive(Control namingContainer) +421 System.Web.UI.Control.InitRecursive(Control namingContainer) +421 System.Web.UI.Control.InitRecursive(Control namingContainer) +421 System.Web.UI.Control.InitRecursive(Control namingContainer) +421 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2098

Do you have any idea how I can stop this exception from being thrown? Also CustomErrors are ON for this site and it bypasses the error page, instead it shows the exception. I just want to prevent the users from seeing this ugly exception.

1

1 Answers

0
votes

It sounds like you are attempting to access the users profile when they are no longer authenticated. I would reccomend that you consider implementing a Login View OR checking for authentication before accessing the users profile properties:

  1. Login View: http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.loginview.anonymoustemplate(v=vs.100).aspx

  2. Check Authentication: http://msdn.microsoft.com/en-us/library/system.web.httprequest.isauthenticated(v=vs.90).aspx