问题描述
第一季度本书建议在注册新的 SqlProfileProvider 之前,应使用< clear>
元素删除所有现有的配置文件提供程序.但是:
Q1Book suggests that before we register new SqlProfileProvider, we should remove any existing profile providers using <clear>
element. But:
A)为什么我们必须使用< clear>
而不是< remove>
?
A) why must we use <clear>
instead of <remove>
?
B)我假设根 web.config 或 machine.config 不注册(默认情况下)任何配置文件提供程序,因此使用<是否需要clear>
元素?
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?
第二季度我认为每个配置文件属性在数据库表中没有对应列(而是将所有属性存储在单个字段中)的原因是由于每次添加和删除配置文件属性时,我们也需要进行更改表架构?
Q2I 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?
感谢
推荐答案
实际上,默认情况下默认添加 AspNetSqlProfileProvider
(类型为 System.Web.Profile.SqlProfileProvider
)在 machine.config
中.查看您的 C:\ Windows \ Microsoft.NET \ Framework \ v2.0.50727 \ CONFIG
目录(或其他位置).但是,它没有在那里注册为默认提供程序.因此,如果您对默认设置感到满意,则足以使用以下配置:
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.
不使用 remove
的原因是它需要一个 name
属性,您可能不知道.使用 clear
删除所有先前注册的配置文件提供程序,使用 remove
删除仅一个名称的文件.
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).
这篇关于删除现有的配置文件提供程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!