码迷,mamicode.com
首页 > Web开发 > 详细

了解认识asp.net运行机制

时间:2018-05-31 19:13:32      阅读:157      评论:0      收藏:0      [点我收藏+]

标签:except   nbsp   exce   说明   eric   generic   参数   ted   init   

 

 

asp.net  运行机制

技术分享图片

 

  下面了解认识httpModule

 

要创建一个httpModule类

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// models 的摘要说明
/// </summary>
public class models:IHttpModule
{
public models()
{
//
// TODO: 在此处添加构造函数逻辑
//
}

public void Dispose()
{
throw new NotImplementedException();
}

public void Init(HttpApplication context)
{
context.BeginRequest+=context_BeginRequest;
context.EndRequest+=context_EndRequest;
}

private void context_EndRequest(object sender, EventArgs e)
{
HttpApplication app = sender as HttpApplication; //全局变量
app.Response.Write("<h1>结束</h1>");
}

private void context_BeginRequest(object sender, EventArgs e)
{
HttpApplication app = sender as HttpApplication; //全局变量
app.Response.Write("<h1>开始好像没用了</h1>");
}
}

 

 

技术分享图片

然后再配置web.config配置相关操作

这里有两个参数  ,name 与type  (type必须与你上面创建的httpmodule相同) 

 

技术分享图片

 

 

 技术分享图片

 

 

 

注意,  需经过多个httpModule

 

了解认识asp.net运行机制

标签:except   nbsp   exce   说明   eric   generic   参数   ted   init   

原文地址:https://www.cnblogs.com/whatarey/p/9117705.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!