2012-06-20 16 views
2

當運行應用程序,我得到異常的的Application_Error處理程序:映像路徑正在搜索控制器

The controller for path '/Content/images/ui-bg_glass_65_ffffff_1x400.png' was not found or does not implement IController. 

任何人能解釋我爲什麼映像路徑解釋MVC行動

MVC路由器等效控制器搜索

這種行爲真的很奇怪。任何幫助,將不勝感激。

+0

入住這 http://stackoverflow.com/questions/2513058/controller-path-not-found-for-static-images-asp- net-mvc-routing-issue – Yasser

回答

2

我認爲這是因爲圖像不存在於您的文件系統(IIS首先檢查靜態內容的文件系統)。 嘗試在Global.asax的路線註冊下面的代碼使用方法:

protected void Application_Start() 
{ 
    RegisterRoutes(RouteTable.Routes); 
} 
public static void RegisterRoutes(RouteCollection routes) 
{ 
    routes.IgnoreRoute("/Content/{*path}"); 
} 
+0

這不起作用。我得到編譯時錯誤。 –

+0

@SanjaySutar答案已更新。 –