使用asp.net4.0的url路由后,能否禁止直接访问真实的aspx文件?
------解决方案--------------------------------------------------------
自己实现IHttpMoudle
- C# code
public class MyHttpModule:IHttpModule { #region IHttpModule 成员 public void Dispose() { } public void Init(HttpApplication context) { context.BeginRequest += Application_BeginRequest; } private void Application_BeginRequest(object sender, EventArgs e) { HttpApplication application = (HttpApplication)sender; HttpContext context = application.Context; string url = context.Request.RawUrl; if (!context.Request.RawUrl.Contains(".aspx")) { //你想要的操作 } context.RewritePath(url); } #endregion }