ASP.NET Routing从数据生成虚拟路径。说明白点就是想用asp.net routing完成如下功能将实际路径:/web/list/lstPage.aspx?id=N;(N:为一组连续的ID)
生成为:/web/list/N/(N:为一组连续的ID)
懂此技术的高手给个例子先,谢过~!

解决方案 »

  1.   

    刚看了一个帖子差不多,请参考public class UrlRewriter:IHttpModule
    {
        public UrlRewriter()
        {
            //
            // TODO: 在此处添加构造函数逻辑
            //
        }    #region IHttpModule 成员    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)
        {
            HttpApplication app = (HttpApplication)sender;
            //得到请求的路径就是你的 web/list/lstPage.aspx?id=N
            string requestUrl = app.Context.Request.Path;        if (requestUrl != null)
            {
                 //你可以随意对requestUrl做判断和处理
                 string rewritePath = ...;
                 //最后重定向到自己的路径
                 app.Context.RewritePath(rewritePath);
            }
        }
        #endregion
    }
      

  2.   

    楼上的几位,URL重写本人会的我是想学学这个ASP.NET Routing从数据生成虚拟路径。还有什么不明白的???