Click here to Skip to main content
15,124,187 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:
HTML
<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 Control:
C#
<asp:SiteMapPath ID="SiteMapPath1" runat="server" SkipLinkText="">


Routing in Global.asax:
C#
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.
Posted
Updated 13-Feb-12 17:31pm
v15
Comments
Sunasara Imdadhusen 17-Oct-11 7:22am
   
Please provide snippet of code!
zhgfsh 25-Oct-11 10:20am
   
thank you, i updated with few code

Hi,

I think its not matching

"home/" to "home"

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

C#
 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
   
C#
routes.Add("home", new Route("home", new SiteRouteHandler() { PageVirtualPath = "~/default.aspx" })); 
        routes.Add("homedefault", new Route("", new SiteRouteHandler() { PageVirtualPath = "~/default.aspx" })); 
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900