2009-07-07 48 views
3

這是我的路由表,我在哪裏放置各種'.aspx'註冊?部署asp.net mvc iis6.0如何更改路由TO包括.aspx

//Turns off the unnecessary file exists check 
this._Routes.RouteExistingFiles = true; 

//Ignore text, html, xml files. 
this._Routes.IgnoreRoute("{file}.txt"); 
this._Routes.IgnoreRoute("{file}.htm"); 
this._Routes.IgnoreRoute("{file}.html"); 
this._Routes.IgnoreRoute("{file}.xml"); 

//Ignore axd files such as assest, image, sitemap etc 
this._Routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); 

//Ignore the assets directory which contains images, js, css & html 
this._Routes.IgnoreRoute("Assets/{*pathInfo}"); 

//Ignore the error directory which contains error pages 
this._Routes.IgnoreRoute("ErrorPages/{*pathInfo}"); 

//Exclude favicon (google toolbar request gif file as fav icon) 
this._Routes.IgnoreRoute("{*favicon}", new { favicon = @"(.*/)?favicon.([iI][cC][oO]|[gG][iI][fF])(/.*)?" }); 

//Photo routes 
this._Routes.MapRoute("PhotoAssets", "Photos/Photo/{photoId}/Size/{photoSizeClassificationId}", MVC.Photo.Photo(0, null)); 

//Handles department profile routes 
this._Routes.MapRoute("WorkerProfileLeader", "Department/{departmentId}/Worker/Profile/Leader/List/{viewType}", MVC.WorkerProfile.List(PersonType.Leader, "", DisplayViewType.SummaryThumbnailList)); 
this._Routes.MapRoute("WorkerProfile", "Department/{departmentId}/Worker/Profile/{personType}/List/{viewType}", MVC.WorkerProfile.List(PersonType.Pleb, "", DisplayViewType.ThumbnailGrid)); 
this._Routes.MapRoute("WorkerProfilePerson", "Department/{departmentId}/Worker/Profile/{personType}/Detail/{personId}", MVC.WorkerProfile.Detail(PersonType.Pleb, "", "")); 

//Default route mapping 
this._Routes.MapRoute("Start", "Default.aspx", MVC.Home.Index()); 
this._Routes.MapRoute("Default", "{controller}/{action}", MVC.Home.Index()); 

乾杯 安東尼

+0

你不需要通配符設置嗎?如phil haack所述 – DevelopingChris 2009-07-07 04:53:45

回答

1

只需確保第一部分或URL與的.aspx像結束:

this._Routes.MapRoute("WorkerProfileLeader", "Department.aspx/{departmentId}/Worker/Profile/Leader/List/{viewType}", ... 
this._Routes.MapRoute("Default", "{controller}.aspx/{action}", MVC.Home.Index()); 
+0

乾杯這就是我想知道 – 2009-07-07 07:08:57

0

我敢肯定它其實並不重要其中在URL中.aspx只要它在某處,並且是第一件看起來是文件擴展名的東西。實際上,我看到的一個技巧是將.aspx放在包含應用程序的文件夾名稱中!換句話說,即使這只是一個文件夾,應用程序名稱本身也是「myapp.aspx」。

只要.aspx作爲路徑中的第一個文件擴展名出現,IIS將使用該文件擴展名來處理請求。

+0

歡呼聲我不知道... – 2009-07-07 23:14:00