【发布时间】:2011-11-30 23:13:25
【问题描述】:
这是有问题的 URL,它会导致我的所有图像都损坏。
http://www.foo.com/payment/receipt/stapia.gutierrez/201110040000034
我的所有内容(图像和诸如此类)都在我的 _Layout.cshtml 文件中声明。我认为这是我的路由问题。
以下是我的 Global.asax 路由区的相关部分:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"AllPayments",
"payment/receipt/{username}",
new { controller = "Payment", action = "AllPayments" }
);
routes.MapRoute(
"IndividualPayment",
"payment/receipt/{username}/{id}",
new { controller = "Payment", action = "SinglePayment" }
);
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
}
这就是我的图像在 _Layout.cshtml 文件中的声明方式:
<img src="../../Content/SiteImages/banner1.jpg" width="200" height="200" />
<img src="../../Content/SiteImages/banner2.jpg" width="200" height="200" />
<img src="../../Content/SiteImages/banner3.jpg" width="200" height="200" />
通常我的图片会src 到
www.foo.com/Content/SiteImages/logo.png,
在这个特定的视图中,它们被更改为
www.foo.com/payment/Content/SiteImages/logo.png
我该如何解决这个问题?是什么导致我的图像 src 在此特定视图中发生变化?
【问题讨论】:
-
标签是什么样的?
标签: c# asp.net-mvc-3 url-routing