C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Articles » ASP.NET/Web Applications »

Changing SiteMap File name


Posted Date: 14 Dec 2008    Resource Type: Articles    Category: ASP.NET/Web Applications
Author: Mohsin MehmoodMember Level: Silver    
Rating: 1 out of 5Points: 11



Changing SiteMap File name


The navigation system introduced in ASP.NET 2.0 allows developers to store the entire website structure in an XML file called sitemap. By default the site navigation system works with the sitemap file named Web.sitemap. What if you want to change the file name to something else say Site.sitemap?
This article will describe how to make your navigation system work with a sitemap file named other than Web.sitemap. If you change your sitemap file name, you will get the following exception:
System.InvalidOperationException: The file web.sitemap required by XmlSiteMapProvider does not exist.

Open your web application root web.config file and add the following code to your web.config in <system.web> element

<siteMap defaultProvider="CustomXmlSiteMapProvider" >

<providers>
<add siteMapFile="Site.sitemap" name="CustomXmlSiteMapProvider" type="System.Web.XmlSiteMapProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</providers>

</siteMap>


The above code registers a XMLSiteMapProvider named CustomXMLSiteMapProvider. You can choose any name for provider you want. siteMapFile attribute specifies the name of the file that provider will use to load navigation data. You will set this attribute’s value to the name of your Sitemap file. In the above mentioned code I have set it to site.sitemap which means I can use the sitemap file named Site.sitemap.


defaultProvider attribute of the siteMap element is essential because it sets the default sitemap provider for application. If this attribute is not included the application will continue using the default AspNetXMLSiteMapProvider which is registered in the Framework’s web.config and uses the Web.sitemap file.

Hope this helps
Mohsin




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
SiteMap in ASP.NET  .  Site Navigation in ASP.NET  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Handling concurrent AJAX requests
Previous Resource: ASP.Net Basic Questions
Return to Discussion Resource Index
Post New Resource
Category: ASP.NET/Web Applications


Post resources and earn money!
 
Related Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use