本帖最后由 caozhy 于 2012-11-29 15:41:57 编辑

解决方案 »

  1.   

    URL重写要如何重写啊!贴一些代码,有案例也可以,可以发到我的邮箱中746436329
      

  2.   

      将以下代码写在这里面 Global.asax   http://www.cheapdresssale.com/ 这个网站用的就是这种方法实现的。自已好好研究吧. 对了。还要引用system.web.routing 
            public static void RegisterRoutes(RouteCollection routes)
            {
                routes.IgnoreRoute("{resource}.axd/{*pathInfo}");           
               //产品详情页。带有html扩展名的伪静态 例如:http://www.cheapdresssale.com/Short-one-shoulder-Homecoming-Party-Dress-with-empire-waist-and-bow-in-back.html
                routes.MapRoute(
    "html",
    "{id}.html",
    new { controller = "Product", action = "html", id = UrlParameter.Optional } // Parameter defaults
    );     //Product为模板页     {id}.html 意思是   Product?id=1210 的重写
                DataBase db = new DataBase();
                RJ.Sql.SelectSqlSection select = new RJ.Sql.SelectSqlSection(RJ.Model.ProductType.TABLENAME)
                .Where(RJ.Model.ProductType.___IsEnable == true);
                select.Reset(RJ.Model.ProductType.___ProductTypeAliasName, RJ.Model.ProductType.___ProductTypeID);
                var list = db.ToIList<RJ.Model.ProductType>(select);
                //产品类型  以产品类型名称作为名称  例如:http://www.cheapdresssale.com/A   http://www.cheapdresssale.com/B
                string key = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
                string keyname = "";
                //产品关键字
                for (int i = 0; i < key.Length; i++)
                {
                    keyname = key.Substring(i, 1);
                    routes.MapRoute(
     string.Format("htmlA{0}",i), // Route name
     keyname + "/{pageIndex}",    // URL with parameters
     new { controller = "ProductKey", action = "List", key = keyname, pageIndex = UrlParameter.Optional } // Parameter defaults
     );
                }        }        protected void Application_Start()
            {            AreaRegistration.RegisterAllAreas();
                RegisterRoutes(RouteTable.Routes);
                //RegisterRoutes(RouteTable.);
               
                
            }
            //void Application_Error(object sender, EventArgs e)
            //{
            //    Exception objErr = Server.GetLastError().GetBaseException();
            //    Server.ClearError();
            //    Response.Clear();
            //    //Response.StatusCode = 404;
            //    //Response.Write(html404);
            //    //Response.End();
            //    //在出现未处理的错误时运行的代码        //}
        
      

  3.   

      将以下代码写在这里面 Global.asax  
            public static void RegisterRoutes(RouteCollection routes)
            {
                routes.IgnoreRoute("{resource}.axd/{*pathInfo}");           
               //产品详情页。带有html扩展名的伪静态 例如:http://www.cheapdresssale.com/Short-one-shoulder-Homecoming-Party-Dress-with-empire-waist-and-bow-in-back.html
                routes.MapRoute(
    "html",
    "{id}.html",
    new { controller = "Product", action = "html", id = UrlParameter.Optional } // Parameter defaults
    );     //Product为模板页     {id}.html 意思是   Product?id=1210 的重写
               
                //产品关键字  例如:http://www.cheapdresssale.com/A   http://www.cheapdresssale.com/B
                string key = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
                string keyname = "";
                //
                for (int i = 0; i < key.Length; i++)
                {
                    keyname = key.Substring(i, 1);
                    routes.MapRoute(
     string.Format("htmlA{0}",i), // Route name
     keyname + "/{pageIndex}",    // URL with parameters
     new { controller = "ProductKey", action = "List", key = keyname, pageIndex = UrlParameter.Optional } // Parameter defaults
     );
                }        }        protected void Application_Start()
            {            AreaRegistration.RegisterAllAreas();
                RegisterRoutes(RouteTable.Routes);
                //RegisterRoutes(RouteTable.);
               
                
            }
            //void Application_Error(object sender, EventArgs e)
            //{
            //    Exception objErr = Server.GetLastError().GetBaseException();
            //    Server.ClearError();
            //    Response.Clear();
            //    //Response.StatusCode = 404;
            //    //Response.Write(html404);
            //    //Response.End();
            //    //在出现未处理的错误时运行的代码        //}
        这个没那么多多余的代码.. 
      

  4.   

    http://blog.csdn.net/jocklyhu/article/details/5982233
      

  5.   

    Global文件:  protected void Application_Start(object sender, EventArgs e)
            {
                RegisterRouters(RouteTable.Routes);
            }把每一个页面设置一下你想显示的URL,类似以下格式:      
            private void RegisterRouters(RouteCollection route)
            {
                route.MapPageRoute("test", "home/index.html", "~/Main/Home/index.aspx");
            }