我有一个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); }
}
}
我的网页配置如下:
<profile inherits="UserProfile" defaultProvider="SqlProfileProvider">
<providers>
<add
name="SqlProfileProvider"
type="System.Web.Profile.SqlProfileProvider"
connectionStringName="Profile"
applicationName="Management" />
</providers>
</profile>
由于某些原因,当代码执行并且我检索或更新当前用户的配置文件时,它会爆炸。但是,更令人好奇的是FirstName和LastName属性工作正常。只有在访问/更新EmailAddress和TelephoneNumber属性时才会出现错误。
如果我在web.config配置文件部分中为FirstName,LastName,EmailAddress和TelephoneNumber属性添加<properties>
部分,则会显示不同类型的错误 - “已定义属性”或其他内容...
有关如何解决此问题的任何想法?您还需要知道配置文件系统的后端是SQL Azure,而前端是Azure WCF服务。
谢谢,
<bleepzter/>
答案 0 :(得分:3)
您确定要将字段名称与属性名称匹配吗?电子邮件!= EmailAddress&amp;&amp;电话!=电话号码