Click here to Skip to main content
14,388,661 members
Rate this:
Please Sign up or sign in to vote.
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:
<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:
<asp:SiteMapPath ID="SiteMapPath1" runat="server" SkipLinkText="">


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.
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
Rate this:
Please Sign up or sign in to vote.

Solution 1

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
   
Rate this:
Please Sign up or sign in to vote.

Solution 3

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)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100