Freigeben über


WebPartsSection.Personalization Eigenschaft

Definition

Ruft ein WebPartsPersonalization-Objekt ab, das es Ihnen ermöglicht, den Webparts-Personalisierungsanbieter anzugeben und Webparts-Personalisierungsautorisierungen festzulegen.

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

Eigenschaftswert

Ein WebPartsPersonalization-Objekt, das es Ihnen ermöglicht, den Personalisierungsanbieter anzugeben und Personalisierungsautorisierungen festzulegen.

Attribute

Beispiele

Im folgenden Codebeispiel wird die Verwendung der Personalization-Eigenschaft veranschaulicht.

// 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

Gilt für:

Weitere Informationen