0

我正在使用会员资格并创建了一个自定义配置文件,其中包含一个名为 FirstName 的属性。它运行良好,除非会话/cookie 丢失(我还没有弄清楚究竟是哪个,因为它很难重现)。然后,当我访问该站点的任何页面时,都会出现此异常:

[SettingsPropertyNotFoundException:未找到设置属性“FirstName”。] 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(控件命名容器)+186 System.Web.UI.Control.InitRecursive(控件命名容器)+421 System.Web.UI.Control.InitRecursive(控件命名容器)+421 System.Web.UI.Control.InitRecursive(控件命名容器) +421 系统.Web.UI.Control。InitRecursive(控制命名容器)+421 System.Web.UI.Page.ProcessRequestMain(布尔 includeStagesBeforeAsyncPoint,布尔 includeStagesAfterAsyncPoint)+2098

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

4

1 回答 1

0

听起来您正在尝试在用户不再经过身份验证时访问他们的个人资料。我建议您在访问用户配置文件属性之前考虑实施登录视图或检查身份验证:

  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

于 2013-10-24T19:56:48.697 回答