我有一個ASP.Net MVC 2應用程序,它提供了靜態HTML文件作爲一個ActionResult如何編寫一個匹配HTML文件名的路線?
Content(htmlString);
這個HTML包含在它的相對鏈接。即/absdk123.html?t1=somevalue & t2 =其他值
我的路線看起來應該如何匹配這些HTTP請求?我試過這個:
routes.MapRoute(
"LinkRoute", // Route name
"{html}", // URL with parameters
new { controller = "Home", action = "ResolveLink"} // Parameter defaults
);
在動作「ResolveLink」字符串參數始終爲'null'。我如何編寫一個路徑來正確處理這些鏈接?
public ActionResult ResolveLink(string htmlFileName)
{
//test param
return Content(htmlFileName);
}
謝謝!
這不正是我已經在例子中? :) – Nick
不,它不是。您的路由參數爲{html},您的操作參數爲htmlFileName - 它們需要相同;) – frennky