2011-08-25 132 views
0

在我的網站我有以下路由表:MVC 3路由問題

routes.MapRoute("Something", 
       "sites/{company}/{site}/", 
       new { controller = "Home", action = "LoadClientSite" }, 
       new[] { "CorrectOnLine.Controllers" }); 

routes.MapRoute("Default1", // Route name 
       "{company}/{site}/", // URL with parameters 
       new { controller = "Home", action = "DefaultRedirect" }, 
       new[] { "CorrectOnLine.Controllers" } 
      ); 

routes.MapRoute("Default2", // Route name 
       "{company}/{site}/{id}", // URL with parameters 
       new { controller = "Home", action = "DefaultRedirect" }, 
       new[] { "CorrectOnLine.Controllers" } 
      ); 

我使用下面的鏈接調用動作:

@(Html.Action("index", "home", new { area = "ClientsSites", CompanyID = Model.CompanyID, SiteID = Model.SiteID, CategoryID = Model.CategoryID, Message = Model.Message })) 

在視圖中我有一個形象:

<img alt="" src="../../../../../WareHouse/Sites/[email protected](Model.Site.SiteID).jpg" height="250px" width="750px" /> 

問題是,當圖像loades MVC嘗試在路由表中找到圖像src時,conntroller = War eHouse,action =網站。

我怎樣才能使MVC只加載圖像,而不是嘗試加載它作爲視圖?

謝謝, 亞歷克斯

+0

我相信這個帖子會有所幫助。 http://stackoverflow.com/questions/1146652/how-do-i-route-images-using-asp-net-mvc-routing –

回答

0

你可能忽略的是,在.JPG擴展名結尾的所有路徑的路線......

routes.IgnoreRoute("{*alljpeg}", new {[email protected]".*\.jpg(/.*)?"});