ASP.NET MVC ÈëÃÅ3¡¢Routing
ÔÚÒ»¸ö
route
ÖУ¬Í¨¹ýÔÚ´óÀ¨ºÅÖзÅÒ»¸öռλ·ûÀ´¶¨Òå
(
{ and } )
¡£µ±½âÎö
URL
µÄʱºò£¬·ûºÅ
"/"
ºÍ
"."
±»×÷Ϊһ¸ö¶¨Òå·ûÀ´½âÎö£¬¶ø¶¨Òå·ûÖ®¼äµÄÖµÔòÆ¥Å䵽ռλ
·ûÖС£
route
¶¨ÒåÖв»ÔÚ´óÀ¨ºÅÖеÄÐÅÏ¢Ôò×÷Ϊ³£Á¿Öµ¡£
ÏÂÃæÊÇһЩʾÀý
URL
£º
Valid route definitions
Examples of matching URL
{controller}/{action}/{id}
/Products/show/beverages
{table}/Details.aspx
/Products/Details.aspx
blog/{action}/{entry}
/blog/show/123
{reporttype}/{year}/{month}/{day}
/sales/2008/1/5
ͨ³££¬ÎÒÃÇÔÚGlobal.asax
ÎļþÖеÄApplication_Start
ʼþÖÐÌí¼Óroutes£¬ÕâÈ·
±£routesÔÚ³ÌÐòÆô¶¯µÄʱºò¾Í¿ÉÓ㬶øÇÒÒ²ÔÊÐíÔÚÄã½øÐе¥Ôª²âÊÔµÄʱºòÖ±½Óµ÷Óø÷½·¨¡£Èç¹ûÄãÏëÔÚµ¥Ôª²âÊÔµÄʱºòÖ±½Óµ÷ÓÃËü£¬×¢²á¸ÃroutesµÄ·½
·¨±ØÐèÊǾ²Ì¬µÄͬʱÓÐÒ»¸öRouteCollection
²ÎÊý¡£
ÏÂÃæµÄʾÀýÊÇ
Global.asaxÖеĴúÂ룬ÑÝʾÁËÌí¼ÓÒ»¸ö°üº¬Á½¸öURL²ÎÊýaction
ºÍ
categoryName
µÄ
Route¶ÔÏó£º
public
static
void
RegisterRoutes(RouteCollection routes)
{
//
ºöÂÔ¶Ô.axdÎļþµÄRoute£¬Ò²¾ÍÊǺÍWebFormÒ»ÑùÖ±½ÓÈ¥·ÃÎÊ.axdÎļþ
routes.IgnoreRoute(
"
{resource}.axd/{*pathInfo}
"
);
routes.MapRoute(
"
Category
"
,
//
Route µÄÃû³Æ
"
Category/{action}/{categoryName}
"
,
//
´øÓвÎÊýµÄURL
new
{ controller
=
"
Category
Ïà¹ØÎĵµ£º
啟動£ºMicrosoft .NET Framework 2.0 Configuration-->Runtion Security Policy-->ÓÒ鍵-->Adjust Security-->Make changes to this &nbs ......
ÔÚ´´½¨ÍøÕ¾ÖУ¬³£³£»áʹÓõ½Éí·ÝÑéÖ¤¡£asp.netÖÐÄÚÖÃÁ˼¸ÖÖÉí·ÝÑéÖ¤µÄ·½Ê½£¬ÈçWindows¡¢froms¡¢PassportµÈ¡£Õ⼸ÖÖÉí·ÝÑéÖ¤µÄ·½Ê½¸÷Óв»Í¬¡£
Ò»°ãÀ´Ëµ£¬ÍøÕ¾µÄÉí·ÝÑéÖ¤·½Ê½¶¼»á¾¹ýÒÔϼ¸¸ö²½Ö裺
1¡¢ÊäÈëÓû§ÃûºÍÃÜÂ룬µ¥»÷È·¶¨°´Å¥¡£
2¡¢ÔÚºǫ́ÅжÏÓû§ÃûºÍÃÜÂëÊÇ·ñÕýÈ·£¬Èç¹û´íÎó·µ»ØÌáʾ£»Èç¹ûÕýÈ·£¬½øÈë¿É·ÃÎʵÄÒ ......
ÓÃVS¿ª·¢ASP.NETÍøÕ¾³ÌÐòµÄʱºò,»á½«Àà»òWeb Services·ÅÔÚÌØÊâµÄÎļþ¼ÐÖÐ,·²ÊÇ·ÅÔÚÕâЩÌØÊâµÄÎļþ¼ÐÖÐ(App_Themes³ýÍâ)µÄ³ÌÐò»òÄÚÈÝÖ»ÔÊÐíÓ¦ÓóÌÐò·ÃÎÊ,¶ÔÓÚÍøÒ³µÄRequestÔò²»ÓèÏìÓ¦(ÎÞ·¨¶ÁÈ¡).
Îļþ¼Ð &nbs ......
£¨×ª ÔÎĵØÖ·http://blog.sina.com.cn/s/blog_524c848901009e7b.html~type=v5_one&label=rela_nextarticle ×÷Õß
ÀîÑóµÄ²©¿Í
http://blog.sina.com.cn/liiyang£©
66.Èí¼þ¿ª·¢¹ý³ÌÒ»°ãÓм¸¸ö½×¶Î£¿Ã¿¸ö½×¶ÎµÄ×÷Óã¿
´ð£ºÐèÇó·ÖÎö£¬¼Ü¹¹Éè¼Æ£¬´úÂë±àд£¬QA£¬²¿Êð
67.ÔÚc#ÖÐusingºÍnewÕâÁ½¸ö¹Ø¼ü×ÖÓÐʲôÒâÒ壬 ......