Removing existing profile providers

吃可爱长大的小学妹 提交于 2019-12-11 15:48:49

问题



Q1 Book suggests that before we register new SqlProfileProvider, we should remove any existing profile providers using <clear> element. But:

A) why must we use <clear> instead of <remove>?

B) I assume that root web.config or machine.config don’t register (by default) any profile provider, and thus using <clear> element is not necessary?


Q2 I assume reason why each profile property doesn’t have a corresponding column in a database table ( instead all properties are stored into a single field ) is due to the fact each time we would add and remove profile properties, we would also need to change table schema?


thanx


回答1:


Actually, the AspNetSqlProfileProvider (of type System.Web.Profile.SqlProfileProvider) is added by default in machine.config. Take a look at your C:\Windows\Microsoft.NET\Framework\v2.0.50727\CONFIG directory (or another location). However, it is not registered as the default provider there. So if you are satisfied with the default settings, it is enough to use the following configuration:

<profile enabled="true" defaultProvider="AspNetSqlProfileProvider" />

If you want to use a custom provider, it's usually a good idea to clear all existing providers (although not necessary) and name another default provider.

The reason for not using remove is that it requires a name attribute, which you may not know. Using clear removes all previously registered profile providers, using remove removes just one by name.

Concerning Q2 you´re correct. The database scheme that is used must be general enough to accomodate lots of different properties (and types of properties).




回答2:


Following on from RWWilden's answer, there is a SQL Table Profile Provider available, that does map properties into columns in a database:

Table Profile Provider Samples

ScottGu had a brief introduction to them here:

ASP.NET 2.0 SQL Table Profile Provider



来源:https://stackoverflow.com/questions/890427/removing-existing-profile-providers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!