我有一个图像文件夹存储在 ~/Content/Images/
我正在通过
加载这些图片<img src="/Content/Images/Image.png" />
最近,图像没有加载,我的错误日志中出现以下错误。奇怪的是,有些图像可以正常加载,而另一些则无法加载。
有人知道我的路线有什么问题吗?我是否缺少/Content/文件夹的忽略路由?
对于 favicon.ico 和一堆其他图像文件,我也遇到了同样的错误...
<Fatal> -- 3/25/2010 2:32:38 AM -- System.Web.HttpException: The controller for path '/Content/Images/box_bottom.png' could not be found or it does not implement IController.
at System.Web.Mvc.DefaultControllerFactory.GetControllerInstance(Type controllerType)
at System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext requestContext, String controllerName)
at System.Web.Mvc.MvcHandler.ProcessRequest(HttpContextBase httpContext)
at System.Web.Mvc.MvcHandler.ProcessRequest(HttpContext httpContext)
at System.Web.Mvc.MvcHandler.System.Web.IHttpHandler.ProcessRequest(HttpContext httpContext)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
我目前的路线是这样的:
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = "" } // Parameter defaults
);
routes.MapRoute(
"ControllerDefault", // Route name
"{controller}/project/{projectid}/{action}/{searchid}", // URL with parameters
new { controller = "Listen", action = "Index", searchid = "" } // Parameter defaults
);
谢谢!
最佳答案
我会在第一个路由下面插入另一个被忽略的路由。
routes.IgnoreRoute("Content/Images/{*pathInfo}");
关于c# - 找不到静态图像的 Controller 路径? asp.net mvc 路由问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2513058/