成员资格设置属性未找到会话丢失后的异常

本文关键字:会话 异常 设置 属性 成员 | 更新日期: 2023-09-27 18:36:42

我正在使用成员资格,并创建了一个自定义配置文件,其中包含一个名为 FirstName 的属性。除非会话/cookie丢失,否则它运行良好(我还没有弄清楚确切的,因为它很难复制)。然后,当我访问网站的任何页面时,我收到此异常:

[设置属性

未找到异常:设置属性"名字"不是 找到了。 System.Configuration.SettingsBase.GetPropertyValueByName(String 属性名称) +8757578 System.Configuration.SettingsBase.get_Item(字符串属性名称) +118 System.Web.Profile.ProfileBase.GetInternal(String propertyName) +49 System.Web.Profile.ProfileBase.get_Item(字符串属性名称) +129 WebFrontend.Security.SecurityHandler.get_FullName() +168 WebFrontend.Controls.LoginInfo.SetupLoginStatus() +15 System.Web.UI.Control.InitRecursive(Control nameingContainer) +186 System.Web.UI.Control.InitRecursive(Control nameingContainer) +421 System.Web.UI.Control.InitRecursive(Control nameingContainer) +421 System.Web.UI.Control.InitRecursive(Control nameingContainer) +421 System.Web.UI.Control.InitRecursive(Control nameingContainer) +421 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, 布尔值包含阶段后异步点) +2098

您知道我如何阻止此异常被抛出吗?此外,此站点的自定义错误已打开,它绕过了错误页面,而是显示异常。我只是想防止用户看到这个丑陋的异常。

成员资格设置属性未找到会话丢失后的异常

听起来您正在尝试访问不再进行身份验证的用户配置文件。我建议您考虑在访问用户配置文件属性之前实现登录视图或检查身份验证:

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

  2. 检查身份验证:http://msdn.microsoft.com/en-us/library/system.web.httprequest.isauthenticated(v=vs.90).aspx