3
我發現ASP.Net mvc的路由機制的限制,我試圖找到一種解決方法。擴展Asp.Net MVC路由機制
我張貼了關於我是有這個問題一個相關的問題here。
問題的要點是,路由與一個結束。 (句點)從不由默認路由機制處理。總是拋出「無法找到資源」錯誤。例如,它不能處理這些URL:
http://www.wikipediamaze.com/wiki/Washington,_D.C.
http://www.wikipediamaze.com/wiki/anythingendinglikethis.
,如果我將其更改爲查詢參數這樣它工作正常:
http://www.wikipediamaze.com/wiki/?topic=Washington,_D.C.
我試圖找到在路由機制,可擴展性點幫我解決這個問題。我嘗試過其他的解決辦法是這樣的:
//Global.asax.cs
protected void Application_Error()
{
var url = HttpContext.Current.Request.RawUrl;
if(TopicRegex.IsMatch(url))
{
var fixedUrl = FixUrlPath(url);
//This throws an error
Response.Redirect(fixedUrl);
//This also throws an error
Server.Transfer(fixedUrl);
}
}
我猜的的Response.Redirect和Server.Transfer的拋出錯誤,因爲在MVC你應該調用來自控制器的RedirectToAction方法。當然,我甚至不能得到控制器。
這似乎是考慮到維基百科使用處理此就好了Apache服務器的一個相當大的限制。試試吧http://en.wikipedia.org/wiki/Washington,_D.C.如果有人可以請在這裏提供一些幫助,我將不勝感激。
嘗試一下我自己,我看到時間順利通過沒有任何問題。你能發表一個你正在定義的路線和他們映射到的控制器的例子嗎? – tghw 2009-06-03 17:33:49
http://stackoverflow.com/questions/429963/the-resource-cannot-be-found-error-when-there-is-a-dot-at-the-end-of-the-url – GuyIncognito 2009-06-03 17:50:55