本文整理汇总了C#中System.Web.HttpApplication.LogRequest事件的典型用法代码示例。如果您正苦于以下问题:C# HttpApplication.LogRequest事件的具体用法?C# HttpApplication.LogRequest怎么用?C# HttpApplication.LogRequest使用的例子?那么恭喜您, 这里精选的事件代码示例或许可以为您提供帮助。您也可以进一步了解该事件所在类System.Web.HttpApplication
的用法示例。
在下文中一共展示了HttpApplication.LogRequest事件的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ModuleExampleTestCS
//引入命名空间
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.
}
}
}
}
}