gpt4 book ai didi

c# - 如何在实现 Url 路由后修复路径(ASP.NET 4.0 webforms)

转载 作者:太空宇宙 更新时间:2023-11-03 11:36:25 24 4
gpt4 key购买 nike

我有 route.Ignore("{resource}.axd/{*pathInfo}");在我的全局。

我在我的网站中使用 ResolveUrl 来指向我的 .js 和 .css 文件

我所有的链接都是用 GetRouteUrl 生成的

但是

我的图像都不起作用。我所有的图像都来自“ResizeHandler”.ashx 文件: <img src='ResizeHandler.ashx?file={0}&width=320&height=160' />

我是以某种方式忽略全局路由中的 .ashx 文件,还是以某种方式使用 Server.MapPath、PhysicalApplicationPath 或其他?最好的解决办法是什么?我试过了 src="/ResizeHa... (注意“/”)- 不起作用。它会跳过项目文件夹回到 localhost:666/ResizeHandler.ashx。

-谢谢

最佳答案

在 Global.asax 文件中我放了这个:

void RegisterRoutes(System.Web.Routing.RouteCollection routes)
{
routes.Ignore("{resource}.axd/{*pathInfo}");
routes.Ignore("{resource}.ashx/{*pathInfo}");

// Register a route for someurl/{somename}
// Other code here !
}

以我个人的经验,工作对我来说还不错;我希望你也一样。

关于c# - 如何在实现 Url 路由后修复路径(ASP.NET 4.0 webforms),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6149873/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com