我有這個在我的全球MVC3自定義路由與虛擬目錄的問題
//custom route
routes.MapRoute(
"DownloadInstall", // Route name
"{controller}/{action}/{id}/{logonserver}", // URL with parameters
new { controller = "Software",
action = "DownloadInstall" } // Parameter defaults
);
//custom route
routes.MapRoute(
"DownloadHelp", // Route name
"{controller}/{action}/{id}/{logonserver}", // URL with parameters
new { controller = "Software",
action = "DownloadHelp" } // Parameter defaults
);
//default route
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Software", action = "Index",
id = UrlParameter.Optional } // Parameter defaults
);
,我調用javascript中的自定義路徑(這偉大工程)是這樣的:
window.location.href = '/Software/DownloadHelp/' + @Model.ID +'\/' +
getLogonServer();
然而,一旦當我將它移動到一個具有虛擬目錄的IIS7盒子時,我的默認路由足夠智能,可以預先配置虛擬名稱......但是,我找不到基於javascript的路由,因爲虛擬目錄未被預先佔用。
這就是爲什麼你應該使用'Html','Ajax'和'Url'助手生成您的鏈接... – 2011-04-05 17:09:58
Sergi ... thx ...我試過,但無法獲得正確的形式的JavaScript變量我試過這個window.location.href = @ Url.Action(「Software」,「DownloadInstall」,new RouteValueDictionary(new {id = @ Model.ID,getLogonServer()}),null); – Bayrat 2011-04-05 18:04:01