업데이트: 2007년 11월
ASP.NET에서 현재 요청에 대한 로깅을 수행하기 직전에 발생합니다.
네임스페이스:
System.Web 어셈블리:
System.Web(System.Web.dll)
Public Event LogRequest As EventHandler
Dim instance As HttpApplication
Dim handler As EventHandler
AddHandler instance.LogRequest, handler
public event EventHandler LogRequest
public:
event EventHandler^ LogRequest {
void add (EventHandler^ value);
void remove (EventHandler^ value);
}
/** @event */
public void add_LogRequest (EventHandler value)
/** @event */
public void remove_LogRequest (EventHandler value)
JScript에서는 이벤트를 지원하지 않습니다.
오류가 발생한 경우에도 LogRequest 이벤트가 발생합니다. LogRequest 이벤트에 대한 이벤트 처리기를 제공하여 요청의 사용자 지정 로깅을 수행할 수 있습니다.
이벤트를 처리하는 방법에 대한 자세한 내용은 이벤트 사용을 참조하십시오.
LogRequest는 .NET Framework 버전 3.5에서 도입되었습니다. 자세한 내용은 .NET Framework 3.5 아키텍처를 참조하십시오.
다음 예제에서는 LogRequest 이벤트에 대한 이벤트 처리기를 제공하는 방법을 보여 줍니다. 이 이벤트 처리기는 다른 여러 이벤트도 처리합니다. 따라서 실행할 코드를 결정하기 위해 CurrentNotification 및 IsPostNotification 속성이 사용됩니다.
Imports System
Imports System.Data
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports Microsoft.VisualBasic
' Module that demonstrates one event handler for several events.
Namespace Samples
Public Class ModuleExampleTestVB
Implements IHttpModule
Public Sub New()
' Constructor
End Sub
Public Sub Init(ByVal app As HttpApplication) Implements IHttpModule.Init
AddHandler app.AuthenticateRequest, AddressOf Me.App_Handler
AddHandler app.PostAuthenticateRequest, AddressOf Me.App_Handler
AddHandler app.LogRequest, AddressOf Me.App_Handler
AddHandler app.PostLogRequest, AddressOf Me.App_Handler
End Sub
Public Sub Dispose() Implements IHttpModule.Dispose
End Sub
' One handler for AuthenticationRequest, PostAuthenticateRequest,
' LogRequest, and PostLogRequest events
Public Sub App_Handler(ByVal source As Object, ByVal e As EventArgs)
Dim app As HttpApplication = CType(source, HttpApplication)
Dim context As HttpContext = app.Context
If (context.CurrentNotification = RequestNotification.AuthenticateRequest) Then
If Not (context.IsPostNotification) Then
' Put code here that is invoked when the AuthenticateRequest event is raised.
Else
' PostAuthenticateRequest
' Put code here that runs after the AuthenticateRequest event completes.
End If
End If
If (context.CurrentNotification = RequestNotification.LogRequest) Then
If Not (context.IsPostNotification) Then
' Put code here that is invoked when the LogRequest event is raised.
Else
' PostLogRequest
' Put code here that runs after the LogRequest event completes.
End If
End If
End Sub
End Class
End Namespace
using System;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
// Module that demonstrates one event handler for several events.
namespace Samples
{
public class ModuleExampleTestCS : IHttpModule
{
public ModuleExampleTestCS()
{
// Constructor
}
public void Init(HttpApplication app)
{
app.AuthenticateRequest += new EventHandler(App_Handler);
app.PostAuthenticateRequest += new EventHandler(App_Handler);
app.LogRequest += new EventHandler(App_Handler);
app.PostLogRequest += new EventHandler(App_Handler);
}
public void Dispose()
{
}
// One handler for AuthenticationRequest, PostAuthenticateRequest,
// LogRequest, and PostLogRequest events
public void App_Handler(object source, EventArgs e)
{
HttpApplication app = (HttpApplication)source;
HttpContext context = app.Context;
if (context.CurrentNotification == RequestNotification.AuthenticateRequest)
{
if (!context.IsPostNotification)
{
// Put code here that is invoked when the AuthenticateRequest event is raised.
}
else
{
// PostAuthenticateRequest
// Put code here that runs after the AuthenticateRequest event completes.
}
}
if (context.CurrentNotification == RequestNotification.LogRequest)
{
if (!context.IsPostNotification)
{
// Put code here that is invoked when the LogRequest event is raised.
}
else
{
// PostLogRequest
// Put code here that runs after the LogRequest event completes.
}
}
}
}
}
.NET Framework 및 .NET Compact Framework에서 모든 플랫폼의 전체 버전을 지원하지는 않습니다. 지원되는 버전의 목록을 보려면 .NET Framework 시스템 요구 사항을 참조하십시오.
.NET Framework
3.5 SP1, 3.0 SP1, 2.0 SP1에서 지원
참조