2011-08-25 135 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(/.*)?"});