62,046
社区成员
发帖
与我相关
我的任务
分享
public class HttpModule : IHttpModule
{
private HttpContext context;
private string Root;
private string Url;
public void Dispose()
{
}
public void Init(HttpApplication context)
{
this.context = context.Context;
Root = this.context.Request.ApplicationPath;
context.BeginRequest += new EventHandler(Application_BeginRequest);
}
private void Application_BeginRequest(object sender, EventArgs e)
{
context = sender.To<HttpApplication>().Context;
Url = context.Request.Url.LocalPath.ToLower();
if (string.IsNullOrEmpty(Url.RegExReplace(Root+"/index", "")))
{
context.RewritePath(Root+"/Index.aspx");
}
}
}
<httpModules>
<add type="xinchen.Web.HttpModule" name="UrlRewriter" />
</httpModules>