首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

5.1Url跟Routes介绍

2012-12-23 
5.1Url和Routes介绍5.1Url和Routes介绍关于Urls-域名好记好拼写-URL尽量短-URL好输入(&少用特殊字符)-URL

5.1Url和Routes介绍
5.1Url和Routes介绍

关于Urls
-域名好记好拼写
-URL尽量短
-URL好输入  (&少用特殊字符)
-URL可以体现网站的结构 (逻辑结构)
-URL规律性强,用户可以自行猜测构造
-URL固定,并持久不变
以前的例子
http://example.com/products/list.aspx?id=123&catid=3333&page=3
URL和硬盘文件相关,
多数情况下,HTML模板,


ASP.NET MVC Routing介绍
-接受用户输入并指向Controller的Action
-把Controller的Action输出成URLs

Routing与URLRewriting技术的比较
1、
Rewriting还是可以看到
-/product/bolts.aspx
-/product/display.aspx?jproductid=123
Routing从根上解决问题
不会重写URL
2、ReWriting是单向的
Routing是双向的。

2011-4-15 23:43 danny
定义Routes
-Route URLs
routes.MapRoute("simple","{first}/{second}/{third}");


URL                                                  URL拆分结果
/product/display/123                           {first}=product {second}=display {third}=123
/foo/bar/baz                                      {first}=foo {second}=bar {third}=baz
/a.b/c-d/e-f                                       {first}="a.b" {second}="c-d" {third}="e-f"

Controller Action id
routes.MapRoute(  "Default", "{controller}/{action}/{id}");

2011-4-16 11:35 danny

热点排行