Partager via


WebRequestInformation.FormatToString(WebEventFormatter) Méthode

Définition

Met en forme les informations sur la demande Web.

public:
 void FormatToString(System::Web::Management::WebEventFormatter ^ formatter);
public void FormatToString (System.Web.Management.WebEventFormatter formatter);
member this.FormatToString : System.Web.Management.WebEventFormatter -> unit
Public Sub FormatToString (formatter As WebEventFormatter)

Paramètres

formatter
WebEventFormatter

WebEventFormatter qui contient les paramètres de tabulation et de mise en retrait utilisés pour mettre en forme les informations d’événements d’intégrité web.

Exemples

L’exemple de code suivant montre comment mettre en forme des informations personnalisées.


// Formats Web request event information.
public override void FormatCustomEventDetails(
 WebEventFormatter formatter)
{

    // Add custom data.

    formatter.AppendLine("");
    formatter.AppendLine(
        "Custom Request Information:");

    formatter.IndentationLevel += 1;

    // Display the request information obtained 
    // using the WebRequestInformation object.
    formatter.AppendLine(GetRequestPath());
    formatter.AppendLine(GetRequestUrl());
    formatter.AppendLine(GetRequestUserHostAdddress());
    formatter.AppendLine(GetRequestPrincipal());

    formatter.IndentationLevel -= 1;

    formatter.AppendLine(eventInfo.ToString());
}
' Formats Web request event information.
 Public Overrides Sub FormatCustomEventDetails( _
 ByVal formatter As WebEventFormatter)

     ' Add custom data.
     formatter.AppendLine("")
     formatter.AppendLine("Custom Request Information:")

     formatter.IndentationLevel += 1

     ' Display the request information obtained 
     ' using the WebRequestInformation object.
     formatter.AppendLine(GetRequestPath())
     formatter.AppendLine(GetRequestUrl())
     formatter.AppendLine(GetRequestUserHostAdddress())
     formatter.AppendLine(GetRequestPrincipal())
     formatter.IndentationLevel -= 1

     formatter.AppendLine(eventInfo.ToString())
 End Sub

Remarques

La FormatToString méthode fournit un format uniforme pour les informations d’événement, ce qui est utile si les données d’événement doivent être journalisées et présentées ultérieurement à l’utilisateur. Il est appelé en interne lorsque le fournisseur appelle l’une des ToString méthodes.

S’applique à