【求助】C#伪静态要如何才能够实现 本帖最后由 caozhy 于 2012-11-29 15:41:57 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 URL重写要如何重写啊!贴一些代码,有案例也可以,可以发到我的邮箱中746436329 将以下代码写在这里面 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(); // //在出现未处理的错误时运行的代码 //} 将以下代码写在这里面 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(); // //在出现未处理的错误时运行的代码 //} 这个没那么多多余的代码.. http://blog.csdn.net/jocklyhu/article/details/5982233 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"); } 求一个更新HTML里input的值的方法 windows2008集成SP2简体中文版 。。 问题内详。 为什么不能更新数据??!!!!!!!!! 有关视频捕捉,图像处理,图像识别技术的解决方案 优秀的代码,是什么样子? 谢 eTopFancy(你的美丽我的回忆) 100分请进( 关于SESSION丢失问题的再次提问,散无比多分(500)就为了一个解决 ) 类项目的问题 急啊,高手门帮帮忙啊,在线等... 100分送 C#与ROSE UML方面的问题 comboBox 中的项目如何排序 c#.net,做个进度条,怎么实现?在线等
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();
// //在出现未处理的错误时运行的代码 //}
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();
// //在出现未处理的错误时运行的代码 //}
这个没那么多多余的代码..
{
RegisterRouters(RouteTable.Routes);
}把每一个页面设置一下你想显示的URL,类似以下格式:
private void RegisterRouters(RouteCollection route)
{
route.MapPageRoute("test", "home/index.html", "~/Main/Home/index.aspx");
}