Share via


WebRequestInformation.FormatToString(WebEventFormatter) Método

Definição

Formata as informações de solicitação da 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)

Parâmetros

formatter
WebEventFormatter

O WebEventFormatter que contém as configurações de tabulação e recuo usadas para formatar as informações de eventos de integridade da Web.

Exemplos

O exemplo de código a seguir mostra como formatar informações personalizadas.


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

Comentários

O FormatToString método fornece um formato uniforme para informações de evento, o que é útil se os dados do evento precisarem ser registrados e posteriormente apresentados ao usuário. Ele é chamado internamente quando o provedor invoca um dos ToString métodos.

Aplica-se a