我期待生成一个MVC网站,该网站使用路由完全控制了网址结构。mvc.net动态网址
routes.MapRoute(
"BlogView", // Route name
"view/{blogurl}", // URL with parameters
new { controller = "view", action = "view", productLink = ""} // Parameter defaults
);
routes.MapRoute(
"ProductGrid", // Route name
"category/{category}", // URL with parameters
new { controller = "category", action = "Index", category = "" } // Parameter defaults
);
我现在都有以下网址;
www.myblog.com/view/first-post
www.myblog.com/view/another-post
www.myblog.com/category/code
www.myblog .com/category/example
前两个网址与详细视图相关,后两个网址与类别视图相关。
我有一个具有以下结构的数据库;我确保url(chrUrl)是一个唯一的键。 URL(idurl(INT), chrURL, chrAction, chrController )
我的计划是,它可以查找改写路由查找表,以便follwoing网址重定向至正确的观点和页面网站;
www.myblog.com/first-post
www.myblog.com/another-post
www.myblog.com/code
www.myblog.com/example
这可能吗?除了性能外,这是否有问题,以及我如何处理这个问题?
这对2张桌子来说可能有点过分,但是当你不知道最终会用到多少桌子时,这听起来像是一种合理的方式。无论你走到哪里,我仍然会担心失去网站的hackability部分以及只有单一路径的唯一性问题。 – 2010-01-27 22:24:28