我有一个关于ASP.NET配置文件实现的问题。这是我的个人资料代码:
public class UserProfile: ProfileBase
{
public static void Get()
{
return (UserProfile)Create(Membership.GetUser().UserName);
}
public static void Get(string username)
{
return (UserProfile)Create(username);
}
//this property works
[SettingsAllowAnonymous(false)]
public string FirstName
{
get{ return base.GetProperty("FirstName") as String; }
set{ base.SetPropertyValue("FirstName", value); }
}
//this property works
[SettingsAllowAnonymous(false)]
public string LastName
{
get{ return base.GetProperty("LastName") as String; }
set{ base.SetPropertyValue("LastName", value); }
}
//this property throws "The settings property 'Email' was not found." error.
[SettingsAllowAnonymous(false)]
public string EmailAddress
{
get{ return base.GetProperty("Email") as String; }
set{ base.SetPropertyValue("Email", value); }
}
//this property throws "The settings property 'Telephone' was not found." error.
[SettingsAllowAnonymous(false)]
public string TelephoneNumber
{
get{ return base.GetProperty("Telephone") as String; }
set{ base.SetPropertyValue("Telephone", value); }
}
}我的web配置如下所示:
<profile inherits="UserProfile" defaultProvider="SqlProfileProvider">
<providers>
<add
name="SqlProfileProvider"
type="System.Web.Profile.SqlProfileProvider"
connectionStringName="Profile"
applicationName="Management" />
</providers>
</profile>由于某些原因,当代码执行时,当我检索或更新当前用户的配置文件时,它就会崩溃。然而,更奇怪的是FirstName和LastName属性工作得很好。只有在访问/更新EmailAddress和TelephoneNumber属性时才会出现错误。
如果我在FirstName、LastName、EmailAddress和TelephoneNumber属性的web.config配置文件部分中添加<properties>部分,则会显示不同类型的错误-“属性已定义”或类似的内容...
有什么办法解决这个问题吗?您还需要知道配置文件系统的后端是SQL Azure,而前端是Azure WCF服务。
谢谢,
<bleepzter/>发布于 2011-02-01 03:00:45
是否确实要将字段名称与属性名称进行匹配?电子邮件!= EmailAddress &&电话!= TelephoneNumber
https://stackoverflow.com/questions/4834124
复制相似问题