我們有MVC2映射...ASP.Net MVC2路由可選參數給出404
routes.MapRoute(
"HomeKeepAlive",
"{controller}/KeepAlive/{objectType}/{id}",
new { controller = "Home", action="KeepAlive", objectType = UrlParameter.Optional, id = UrlParameter.Optional }
);
routes.MapRoute(
"DefaultRoute",
"{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
所有服務器的Windows Server 2003 SP2,IIS6安裝.NET 4中。
的路線我們的測試服務器
/Home/Ping
/Home/Ping/1
/Home/KeepAlive/Article
/Home/KeepAlive/Article/5
上,但我們活的服務器上只有網址的工作沒有ID的工作,如
/Home/Ping
/Home/KeepAlive/Article
,而那些有ID給予404
/Home/Ping/1
/Home/KeepAlive/Article/5
鑑於測試服務器的工作原理,我假設這個問題是IIS6上的一個配置問題o你的在線服務器,但我看不到他們之間的任何差異。
以前有沒有人見過類似的東西?
直播服務器是IIS中的網站,而測試服務器是虛擬目錄。 – 2011-02-22 23:23:47
我有一個簡單的解決方法。添加一個額外的「虛擬」url參數。在現場服務器上,現在可以識別id url參數,例如\ Home \ Ping \ 1現在可以工作。如果您嘗試\ Home \ Ping \ 1 \ 2它會給出404,但我沒有任何具有額外參數的網址。 我仍然不明白爲什麼現場服務器有這種行爲。這並不能滿足我的信心。 新映射是... routes.MapRoute( 「Default」, 「{controller}/{action}/{id}/{dummy}」, new {controller =「Home」,action =「Index 「,id = UrlParameter.Optional,dummy = UrlParameter.Optional} ); – 2011-02-23 08:43:05