C# ASP.NET MVC-路由问题
这就是问题中的URL,它会导致我的所有图像中断C# ASP.NET MVC-路由问题,c#,asp.net-mvc-3,url-routing,C#,Asp.net Mvc 3,Url Routing,这就是问题中的URL,它会导致我的所有图像中断 http://www.foo.com/payment/receipt/stapia.gutierrez/201110040000034 我的所有内容(图像等)都在my_Layout.cshtml文件中声明。我相信这是我的路线问题 以下是my Global.asax路由区域的相关部分: public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute
http://www.foo.com/payment/receipt/stapia.gutierrez/201110040000034
我的所有内容(图像等)都在my_Layout.cshtml文件中声明。我相信这是我的路线问题
以下是my 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
);
}
以下是在my_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在这个特定视图中发生更改?因为您正在查看特定的付款,所以您比url更深了一步 在哪里
将在AllPayments页面上工作,您需要
<img src="../../../Content/SiteImages/banner1.jpg" width="200" height="200" />
在个人支付页面上。标签是什么样子的?我认为使用
Url.Content
将是更好的、经得起未来考验的方式。谢谢你让我意识到我忘了用这个。
<img src="../../Content/SiteImages/banner1.jpg" width="200" height="200" />
<img src="../../../Content/SiteImages/banner1.jpg" width="200" height="200" />