WebPartsSection.Personalization Propiedad
Definición
Importante
Parte de la información hace referencia a la versión preliminar del producto, que puede haberse modificado sustancialmente antes de lanzar la versión definitiva. Microsoft no otorga ninguna garantía, explícita o implícita, con respecto a la información proporcionada aquí.
Obtiene un objeto WebPartsPersonalization que permite especificar el proveedor de personalización de elementos Web y establecer autorizaciones de personalización de elementos Web.
public:
property System::Web::Configuration::WebPartsPersonalization ^ Personalization { System::Web::Configuration::WebPartsPersonalization ^ get(); };
[System.Configuration.ConfigurationProperty("personalization")]
public System.Web.Configuration.WebPartsPersonalization Personalization { get; }
[<System.Configuration.ConfigurationProperty("personalization")>]
member this.Personalization : System.Web.Configuration.WebPartsPersonalization
Public ReadOnly Property Personalization As WebPartsPersonalization
Valor de propiedad
Objeto WebPartsPersonalization que permite especificar el proveedor de personalización y establecer las autorizaciones de personalización.
- Atributos
Ejemplos
En el ejemplo de código siguiente se muestra cómo utilizar la propiedad Personalization.
// Get the current DefaultProvider property value.
Console.WriteLine(
"Current DefaultProvider value: '{0}'",
webPartsSection.Personalization.DefaultProvider);
// Set the DefaultProvider property.
webPartsSection.Personalization.DefaultProvider =
"ASPNetSQLPersonalizationProvider";
// Add a provider.
webPartsSection.Personalization.Providers.Add(
new ProviderSettings("CustomProvider",
"MyCustomProviders.Provider"));
// List current providers.
for (int pi = 0;
pi < webPartsSection.Personalization.Providers.Count; pi++)
{
Console.WriteLine(" #{0} Name={1} Type={2}", pi,
webPartsSection.Personalization.Providers[pi].Name,
webPartsSection.Personalization.Providers[pi].Type);
}
// Add an authorization.
AuthorizationRule ar =
new AuthorizationRule(AuthorizationRuleAction.Allow);
ar.Verbs.Add("ModifyState");
ar.Users.Add("Admin");
webPartsSection.Personalization.Authorization.Rules.Add(ar);
// List current authorizations.
for (int ai = 0;
ai < webPartsSection.Personalization.Authorization.Rules.Count;
ai++)
{
Console.WriteLine(" #{0}:", ai);
AuthorizationRule aRule =
webPartsSection.Personalization.Authorization.Rules[ai];
Console.WriteLine(" Verbs=");
foreach (string verb in aRule.Verbs)
Console.WriteLine(" * {0}", verb);
Console.WriteLine(" Roles=");
foreach (string role in aRule.Roles)
Console.WriteLine(" * {0}", role);
Console.WriteLine(" Users=");
foreach (string user in aRule.Users)
Console.WriteLine(" * {0}", user);
}
' Get the current DefaultProvider property value.
Console.WriteLine( _
"Current DefaultProvider value: '{0}'", _
webPartsSection.Personalization.DefaultProvider)
' Set the DefaultProvider property.
webPartsSection.Personalization.DefaultProvider = _
"ASPNetSQLPersonalizationProvider"
' Add a provider.
webPartsSection.Personalization.Providers.Add( _
New ProviderSettings("CustomProvider", _
"MyCustomProviders.Provider"))
' List current providers.
Dim pi As Integer
For pi = 0 To webPartsSection.Personalization.Providers.Count - 1
Console.WriteLine(" #{0} Name={1} Type={2}", pi, _
webPartsSection.Personalization.Providers(pi).Name, _
webPartsSection.Personalization.Providers(pi).Type)
Next
' Add an authorization.
Dim ar As AuthorizationRule = _
New AuthorizationRule(AuthorizationRuleAction.Allow)
ar.Verbs.Add("ModifyState")
ar.Users.Add("Admin")
webPartsSection.Personalization.Authorization.Rules.Add(ar)
' List current authorizations.
Dim ai As Integer
For ai = 0 To _
webPartsSection.Personalization.Authorization.Rules.Count
Console.WriteLine(" #{0}:", ai)
Dim aRule As AuthorizationRule = _
webPartsSection.Personalization.Authorization.Rules(ai)
Console.WriteLine(" Verbs=")
Dim verb As String
For Each verb In aRule.Verbs
Console.WriteLine(" * {0}", verb)
Console.WriteLine(" Roles=")
Next
Dim role As String
For Each role In aRule.Roles
Console.WriteLine(" * {0}", role)
Console.WriteLine(" Users=")
Next
Dim user As String
For Each user In aRule.Users
Console.WriteLine(" * {0}", user)
Next
Next