I’ve got my web forms site (4.0) setup with UrlRouting.
My bread crumb appears when I go to
My main issue is with http://Localhost/
Since it’s defaulting to http://Localhost/default.aspx in IIS
I’m trying to avoid the route of adding another element to the sitemap xml like
<siteMapNode url="~/Home" title="Home" description="Home" aspx="default.aspx">
What would be the best approach to use?
I’ve tried to add this to my routing table & using an xmlSiteMapProvider to see if I could so something with it (which didn’t work).
routes.MapPageRoute("IISDefault", "", "~/Default.aspx");
Here’s some of info.
Routes
routes.MapPageRoute("Default", "Home", "~/Default.aspx");
routes.MapPageRoute("ListAll", "List", "~/ListAll.aspx");
Sitemap
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="~/Home" title="Home" description="Home">
<siteMapNode url="~/List" title="List All" description="List All" />
</siteMapNode>
</siteMap>
XmlSiteMapProvider
/// <summary>
/// This is where the original sitemap node is overloaded. We get the proper translation from the database.
/// </summary>
/// <param name="sender">This is the sender of the event</param>
/// <param name="e">This is the event arguments</param>
/// <returns>Returns a modified SiteMapNode</returns>
/// <remarks></remarks>
public SiteMapNode SmartSiteMapProvider_SiteMapResolve(object sender, SiteMapResolveEventArgs e)
{
SiteMapNode returnValue = null;
if ((SiteMap.CurrentNode == null))
{
// If we don't find a sitemap node, then we might be working with UrlRouting
returnValue = ProcessRoute(e);
}
return returnValue;
}
private SiteMapNode ProcessRoute(SiteMapResolveEventArgs e)
{
SiteMapNode returnValue = null;
System.Web.Routing.RequestContext rc = HttpContext.Current.Request.RequestContext;
if ((rc != null))
{
System.Web.Routing.RouteBase route = rc.RouteData.Route;
if ((route != null))
{
// Play with the node (Never getting here)
}
}
return returnValue;
}
Edit: I’m going to see if I can manipulate the routeCollection to get a match somehow.
Instead of :
try this:
Otherwise “~/” and “~/Home” are the same thing.
or you could leave the above as is and in the default.aspx page do something like this …
That would effectively redirect any default request to your default request.
Your problem is that the server sees ~/” and “~/Home” as being 2 different urls and you basically want them to be the same, so you have to make a decision and decide which one to redirect to the other.
personally if this was my solution I would’nt have a route for “~/Home” and my base node in my sitemap would look something like this:
It’s clean and obvious that “http://yourdomain/” is the homepage and “http://yourdomain/Home” could be anything (about your home, my home, home sweet home, things i like in my home) whereas “http://adomain/” is the homepage across the globe for everyone.