相关示例代码:
UserPro@R_502_6852@.cs
public class UserPro@R_502_6852@: System.Web.Pro@R_502_6852@.Pro@R_502_6852@Base{ public static UserPro@R_502_6852@ GetUserPro@R_502_6852@(string username) { return Create(username) as UserPro@R_502_6852@; } public static UserPro@R_502_6852@ GetUserPro@R_502_6852@() { return GetUserPro@R_502_6852@(Membership.GetUser().Username); } public string FacebookUID { get { return base["FacebookUID"] as string; } set { base["FacebookUID"] = value; } }}
Web.config文件
<pro@R_502_6852@ enabled="true" inherits="WIF.Web.STS.Classes.UserPro@R_502_6852@" defaultProvIDer="XmlPro@R_502_6852@ProvIDer" > <propertIEs> <add name="FacebookUID" /> </propertIEs> <provIDers> <add name="XmlPro@R_502_6852@ProvIDer" type="Artem.Web.Security.XmlPro@R_502_6852@ProvIDer,Artem.Web.Security.Xml" applicationname="/" @R_502_6852@name="Pro@R_502_6852@s.xml" folder="~/App_Data/"/> </provIDers> </pro@R_502_6852@>
Register.aspx.cs
pro@R_502_6852@ = WIF.Web.STS.Classes.UserPro@R_502_6852@.GetUserPro@R_502_6852@(emailAddress); pro@R_502_6852@.FacebookUID = "";
当我离开web.config中定义的FacebookUID时;我从web.config得到这个错误:
Configuration Error: This pro@R_502_6852@ property has already been defined.
我已经仔细检查了web.config;该属性条目仅在web.config中出现一次.
我想这是因为我在UserPro@R_502_6852@类上设置了具有相同名称的属性.我从web.config中删除了属性/ add [name =’FacebookUID’]条目.一旦我做到了;当我尝试在Register.aspx.cs中设置FacebookUID的值时出现此错误:
The settings property 'FacebookUID' was not found line 76: pro@R_502_6852@["FacebookUID"] = "";
我再试一次,这次直接使用Pro@R_502_6852@Base类:
修订了Register.aspx.cs
var pro@R_502_6852@ = System.Web.Pro@R_502_6852@.Pro@R_502_6852@Base.Create(emailAddress,true); pro@R_502_6852@["FacebookUID"] = "";
修改了web.config:
<pro@R_502_6852@ enabled="true" defaultProvIDer="XmlPro@R_502_6852@ProvIDer" > <propertIEs> <add name="FacebookUID" /> </propertIEs> <provIDers> <add name="XmlPro@R_502_6852@ProvIDer" type="Artem.Web.Security.XmlPro@R_502_6852@ProvIDer,Artem.Web.Security.Xml" applicationname="/" @R_502_6852@name="Pro@R_502_6852@s.xml" folder="~/App_Data/"/> </provIDers> </pro@R_502_6852@>
我尝试使用propertIEs / add [name =’FacebookUID’]而没有;在相同的情况下得到与上述相同的错误.
我很难过,谷歌/ Binging让我无处可去.这里有没有人知道可能会发生什么和/或如何解决这个问题?非常感谢任何建设性的意见.
谢谢,
坦率
Notes to inheritors
You can create a custom pro@R_502_6852@ implementation that inherits from the Pro@R_502_6852@Base abstract class and defines propertIEs for the user pro@R_502_6852@ that are not specifIEd in the pro@R_502_6852@ configuration element.
http://msdn.microsoft.com/en-us/library/system.web.profile.profilebase.aspx
另外:你修改过XmlPro@R_502_6852@ProvIDer的代码吗?它似乎期待XmlPro@R_502_6852@,没有别的.
http://www.java2s.com/Open-Source/ASP.NET/Asp.net-Samples/tinyproviders/Artem/Web/Security/XmlProfileProvider.cs.htm
总结以上是内存溢出为你收集整理的c# – ASP.Net配置文件:设置和使用配置文件字段时遇到困难全部内容,希望文章能够帮你解决c# – ASP.Net配置文件:设置和使用配置文件字段时遇到困难所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)