【发布时间】:2015-04-26 15:49:07
【问题描述】:
我正在写一个网页来显示图像。我已使用 asp.net 网络表单 URL 路由导航到此页面。 地图网:
webform1.aspx with master page: site.Master.
'demo.jpg' in folder Images.
demo.jpg is banner of site.Master
2 link in site.Master:
.../home
.../home/gp
网址:
http://localhost:42370/webform1.aspx
重写器:
http://localhost:42370/home
链接图片:
http://localhost:42370/Images/demo.jpg
但是当点击到网址时
http://localhost:42370/home/gp
图片错误和链接图片:
http://localhost:42370/home/gp/Images/demo.jpg
再次点击“主页”时:
http://localhost:42370/home/home
谁能告诉我我在这里做错了什么?
PS:我用过:
routes.Ignore("{*alljpg}", new { alljpg = @".*\.jpg(/.*)?" });
或
routes.Add(new Route("*\.jpg", new StopRoutingHandler()));
但它不起作用 请帮帮我:( 路由到这里:
void RegisterRouter(RouteCollection r)
{
r.MapPageRoute("", "home", "~/webform1.aspx");
r.MapPageRoute("", "home/{grap}", "~/webform1.aspx");
}
protected void Application_Start(object sender, EventArgs e)
{
RegisterRouter(RouteTable.Routes);
}
【问题讨论】:
-
我们需要您的整个路由设置来正确诊断,可能您的顺序错误。路由是自上而下处理的。
-
感谢EBrow,这里是:r.MapPageRoute("", "home", "~/webform1.aspx"); r.MapPageRoute("", "home/{grap}", "~/webform1.aspx");请帮助我
-
将其添加到您的问题中。
-
究竟是什么错误?您也根本不会将忽略添加到您的路由中。
-
我尝试添加忽略,但它不起作用。文件'demo.jpg'直到出错
标签: c# asp.net image webforms routing