当网址以斜杠"/"结尾时,导航不会显示 [英] Navigation do NOT display when the url end with a slash "/"

查看:107
本文介绍了当网址以斜杠"/"结尾时,导航不会显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!

使用网站 www.green-batteries.com 时,在使用ASP.NET4.0编程时遇到了问题网址路由.

当我访问 SiteMapPath控件(导航,与Web.sitemap绑定)显示良好. htm> www.green-batteries.com/products.htm
但是当我在网址末尾添加斜杠(/)时,网址根本不显示(网址看起来像/ )
PS:SiteMapPath位于横幅下.


Web.sitemap提示:

Hi guys!

I come with a problem while i am working with my site www.green-batteries.com, programme ASP.NET4.0 with url routing.

The SiteMapPath Control(navigation, bind with Web.sitemap) display well when i visit www.green-batteries.com/products.htm,
but it does NOT display at all while I add a slash(/) at the url''s end(url looks like www.green-batteries.com/products.htm/)
PS:the SiteMapPath is under the banner.


Web.sitemap tips:

<sitemap xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <sitemapnode url="home" title="Home" description="Home">
     <sitemapnode url="products" title="Products" description="Products">
     <sitemapnode url="news" title="News" description="News">
  </sitemapnode>
</sitemapnode></sitemapnode></sitemap>



SiteMapPath控件:



SiteMapPath Control:

<asp:SiteMapPath ID="SiteMapPath1" runat="server" SkipLinkText="">



在Global.asax中进行路由:



Routing in Global.asax:

void Application_Start(object sender, EventArgs e) 
    {
        RegisterRoutes(RouteTable.Routes);                
    }

 public static void RegisterRoutes(RouteCollection routes)
    {
        routes.MapPageRoute("home", "home", "~/Default.aspx");
        routes.MapPageRoute("products", "products", "~/Products.aspx");
        routes.MapPageRoute("news", "news", "~/News.aspx");
    }



希望你们能帮帮我,谢谢.



Hope your guys can give me a hand, thank you.

推荐答案

您好,

我认为它不匹配

从"home/"到"home"

在Mappageroute表中,您必须为此添加一个标签

Hi,

I think its not matching

"home/" to "home"

in Mappageroute table you''ve to add one more tag for that like

 routes.MapPageRoute("home/", "home", "~/Default.aspx");
routes.MapPageRoute("home", "home", "~/Default.aspx");
        routes.MapPageRoute("products", "products", "~/Products.aspx");
        routes.MapPageRoute("news", "news", "~/News.aspx");



我想它有效


所有最佳



I guess it works


All the Best


routes.Add("home", new Route("home", new SiteRouteHandler() { PageVirtualPath = "~/default.aspx" })); 
        routes.Add("homedefault", new Route("", new SiteRouteHandler() { PageVirtualPath = "~/default.aspx" })); 


这篇关于当网址以斜杠"/"结尾时,导航不会显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆