RT。我用HttpModule代理的形式,实现页面重定向,局部代码如下:
public class UrlReWriteHttpModule : IHttpModule
{
public UrlReWriteHttpModule()
{
//
//TODO: 在此处添加构造函数逻辑
//
}
public void Dispose()
{
//throw new Exception("The method or operation is not implemented.");
} public void Init(HttpApplication context)
{
context.BeginRequest += new EventHandler(context_BeginRequest);
}
void context_BeginRequest(object sender, EventArgs e)
{
(此处省略了一些代码)
HttpContext Context = (sender as HttpApplication).Context;
Context.Response.Redirect(DictionaryClass.Str_FakePath);
}
}
使用这种方式生成了index.aspx页面,点击页面上的按钮button,并不能触发到button_Click事件,而是再次进入HttpModule代理,去请求index.aspx页面。结果可想而知,就是刷新了一下页面而已。现在不知道如何解决,才能够触发按钮事件。
public class UrlReWriteHttpModule : IHttpModule
{
public UrlReWriteHttpModule()
{
//
//TODO: 在此处添加构造函数逻辑
//
}
public void Dispose()
{
//throw new Exception("The method or operation is not implemented.");
} public void Init(HttpApplication context)
{
context.BeginRequest += new EventHandler(context_BeginRequest);
}
void context_BeginRequest(object sender, EventArgs e)
{
(此处省略了一些代码)
HttpContext Context = (sender as HttpApplication).Context;
Context.Response.Redirect(DictionaryClass.Str_FakePath);
}
}
使用这种方式生成了index.aspx页面,点击页面上的按钮button,并不能触发到button_Click事件,而是再次进入HttpModule代理,去请求index.aspx页面。结果可想而知,就是刷新了一下页面而已。现在不知道如何解决,才能够触发按钮事件。
Context.Request.QueryString["ID"] 而不是所有的请求都会去转向
所以是刷新了一下
你可以用httphandler来代替IHttpModule 来实现指定 只接收GET请求
<httpHandlers>
<add verb="get" path="path" type="type" />
</HttpModules>