使用具有重叠属性的多个配置文件提供程序

发布于 2024-07-19 20:57:46 字数 291 浏览 3 评论 0原文

我正在处理一个需要使用两个不同的 ASP.NET 配置文件提供程序的网站。 它们都被添加到 web.config 中,并且它们的属性也都列在那里。 当我尝试启用每个提供程序中具有相同名称的属性时,我遇到了问题。 注释掉其中之一,网站至少会加载。 将两者都留在其中,我会收到类似以下错误:

项目已被添加。 字典中的键:'myfieldname' 添加的键:'MyFieldName'

这些属性完全不同(甚至不同类型),但我不知道如何允许使用两者。

我一定缺少某种方式,因为这似乎可能是一个常见问题。

I am working with a site that needs to use two different asp.net profile providers. They are both added in the web.config and the properties of each of them are listed there as well. I run into a problem when I try to enable a property that has the same name in each provider. Comment one out, and the site will at least load. Leave both in, and I get an error like:

Item has already been added. Key in dictionary: 'myfieldname' Key being added: 'MyFieldName'

The properties are entirely different (different types even), but I am missing how I would allow both to be used.

There must be some way I am missing as this seems like it could be a common problem.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

锦爱 2024-07-26 20:57:46

我只用 Web 应用程序项目实现过单个配置文件系统。 使用网站模板,功能是开箱即用的。 使用 ASP.NET 会员系统时,配置文件允许您为每个用户存储一些额外信息。 当我们将此额外信息添加到 web.config 文件时,配置文件会自动存储在数据库中。

这是有道理的,如果您使用具有相同名称的配置文件属性,则会发生冲突 - 一个可能的解决方案是创建您自己的表映射 - 例如,在 web.config 中为“MyFieldName”指定一个别名,但将其映射到代码中的真实属性名称。 由于网站模板的大部分功能都是开箱即用的,因此您可以执行的自定义量可能会受到限制。

以下链接可能会有所帮助:

http://code.msdn.microsoft.com/WebProfileBuilder

< a href="http://weblogs.asp.net/joewrobel/archive/2008/02/03/web-profile-builder-for-web-application-projects.aspx" rel="nofollow noreferrer">http:// /weblogs.asp.net/joewrobel/archive/2008/02/03/web-profile-builder-for-web-application-projects.aspx

http://weblogs.asp.net/jgalloway/archive/2008/ 01/19/writing-a-custom-asp-net-profile-class.aspx

I've only ever implemented a single profile system with a Web Application project. With the Website template, the functionality is out of the box. Profiles allow you to store some extra information per user when using the ASP.NET membership system. Profiles are stored in the database automatically when we add this extra information to our web.config file.

It makes sense that there would be a clash if you are using profile properties with the same names - a possible solution would be to create your own table mapping - for example, give 'MyFieldName' an alias in the web.config but map it to the real property name in your code. Since much of the functionality is out-of-the-box with the website template, you may be limited in the amount of customization you can perform.

The following links may help:

http://code.msdn.microsoft.com/WebProfileBuilder

http://weblogs.asp.net/joewrobel/archive/2008/02/03/web-profile-builder-for-web-application-projects.aspx

http://weblogs.asp.net/jgalloway/archive/2008/01/19/writing-a-custom-asp-net-profile-class.aspx

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文