今天学到一点小技术:
1.利用"实现类或者相对应的模块"加载时进行初始化判断URL的定向!
a.先建立一个继成IHttpModule接口的类,在Init方法中初始化或者处理事件
// 初始化
public void Init(HttpApplication context)
{
context.BeginRequest += new EventHandler(context_BeginRequest);
}
//处理事件
private void context_BeginRequest(object sender, EventArgs e)
{
HttpContext context = ((HttpApplication)sender).Context;
RewritePost(context);
}
//重写URL
private static void RewritePost(HttpContext context)
{
context.RewritePath("/testHttpModules/post.aspx?id=22", false);
}
b.在配置文件中加入HtppModule模块,以便起动程序时就开始运行IHttpModule中的方法,来处理所需!