Introduction

In this section we will show you how to utilize and install the Subgurim SiteMap provider. 
You will find that it's quite easy, and with just a couple of minutes your Subgurim SiteMap will be generated and working on your website... this is a set and forget installation! ;) 
We suggest you to register your SiteMaps with (Google SiteMaps) and Bing (Webmaster Tools).

Installation and configuration

Installation
The Subgurim SiteMap installation is as easy as it is for any other librery.

  • Download your preferred Subgurim SiteMap version (we suggest the newest one).
  • Paste the ".dll" to your "~/bin" directory.

Important: The Subgurim SiteMap only works on ASP.NET 2.0/3.5/4.0 and later. 


Configuration
Now we have to lightly configure our web.config
Let's start addind an HttpModule that points to the SubgurimSiteMap:

<system.web>
   <httpModules>
     <add name="SubgurimSiteMapContextRequest" type="Subgurim.Controles.SSM.SubgurimSiteMapContextRequest"/>
   </httpModules>
</system.web>

Or for IIS 7.x

<system.webServer>
   <modules runAllManagedModulesForAllRequests="true">
     <add name="SubgurimSiteMapContextRequest" type="Subgurim.Controles.SSM.SubgurimSiteMapContextRequest"/>
   </modules>
</system.webServer>
  

Now we have to add an item inside the "configSections" element: 

<configSections>
   <section name="SubgurimSiteMapConfiguration" type="Subgurim.Controles.SSM.SubgurimSiteMapSectionHandler"/>
</configSections> 

And finally, we will add the next non-predefined element. It has configuration purpuses and we will explain on the next "How To" Y finalmente, añadirmos ese elemento "No predefinido" del que hablábamos. Desde éste haremos unas configuraciones básicas que explicaremos en el próximo artículo explicativo. So we should add:

<SubgurimSiteMapConfiguration>
   <dataPath>...</dataPath>
   <sitemapResponse>...</sitemapResponse>
   <forbiddenPaths>
     <Path></Path>
   </forbiddenPaths>
   <acceptedExtensions>
     <extension>...</extension>
   </acceptedExtensions>
   <rewriterRules>
     <rule>
       <oldPath>...</oldPath>
       <newPath>...</newPath>
     </rule>
   </rewriterRules>
</SubgurimSiteMapConfiguration>

And that's all!
Let's see a complete web.config with the required upgrades:

<web.config>
  <configSections>
     <section name="SubgurimSiteMapConfiguration" type="Subgurim.Controles.SSM.SubgurimSiteMapSectionHandler"/>
  </configSections> 
  <SubgurimSiteMapConfiguration>
     <dataPath>...</dataPath>
     <sitemapResponse>...</sitemapResponse>
     <forbiddenPaths>
       <Path></Path>
     </forbiddenPaths>
     <acceptedExtensions>
       <extension>...</extension>
     </acceptedExtensions>
     <rewriterRules>
       <rule>
         <oldPath>...</oldPath>
         <newPath>...</newPath>
       </rule>
     </rewriterRules>
  </SubgurimSiteMapConfiguration>
  <system.web>
     <httpModules>
       <add name="SubgurimSiteMapContextRequest" type="Subgurim.Controles.SSM.SubgurimSiteMapContextRequest"/>
     </httpModules>
  </system.web> 
</web.config>

Subgurim SiteMapConfiguration

As we commented on the last article, we are going to make the basic configuration issues on the element "SubgurimSiteMapConfiguration". Let's see one by one all the configuration Items: 


dataPath
The directory path on which an XML file will be saved. The Subgurim SiteMaps will use it as a DataBase. This directory SHOULD have write permissions. If it's left empty, the value will be "~/App_Data/SiteMap/" 


sitemapResponse
The final path of the visible SiteMap. Therefore it will be the value that we should indicate to the Google SiteMaps and Yahoo Explorer. It it's left empty, the value will be "~/sitemap.aspx". 


forbiddenPaths
It's quite common that we don't want some paths to be filed on the SiteMap. For example an entire folder of a private zone, or an specific file. Foreach Path we want to hide, we should add a "<Path />" elemento (we will see it on the next example). 


acceptedExtensions
By default, the Subgurim SiteMaps only stores ".aspx" urls. We should add an "<extension />" element, foreach extra extension we want to store. For example, we could want to store url's with ".html" o ".htm" extensions (we will see it on the next example). 


rewriterRules
Another typical feature are the rewritable url's. For examplo, we could request to transform "http://facebook.com" to "http://www.facebook.com", or "http://www.facebook.com/default.aspx" to "http://www.facebook.com". In this way, we will avoid that our SiteMap holds multiple URL that points to the same page. In our example: "http://facebook.com" == "http://www.facebook.com" == "http://www.facebook.com/default.aspx" == "http://facebook.com/default.aspx". Edit this kind of rules is also very easy. Foreach rule, whe will add a "<rule />" element, and inside of it we will add "oldPath" and "newPath" elements (we will see it on the next example). 


Example
Therefore, and example of a "SubgurimSiteMapConfiguration" section will be: 

<SubgurimSiteMapConfiguration>
   <dataPath>~/App_Data/SubgurimSiteMap</dataPath>
   <sitemapResponse>~/sitemapmeplease.aspx</sitemapResponse>
   <forbiddenPaths>
     <Path>~/Admin</Path>
     <Path>~/PrivatePage.aspx</Path>
   </forbiddenPaths>
   <acceptedExtensions>
     <extension>.htm</extension>
     <extension>.html</extension>
   </acceptedExtensions>
   <rewriterRules>
     <rule>
       <oldPath>http://facebook.com</oldPath>
       <newPath>http://www.facebook.com</newPath>
     </rule>
     <rule>
       <oldPath>http://www.facebook.com/default.aspx</oldPath>
       <newPath>http://www.facebook.com</newPath>
     </rule>
   </rewriterRules>
</SubgurimSiteMapConfiguration>

Interaction

In addition to all the automatic features that the Subgurim SiteMap has, you can interact with it with your custom code, using any of the next methods:

  • addSiteMap: adds an url to the Subgurim SiteMap database.
  • deleteSiteMap: deletes an url from the Subgurim SiteMap database.
  • clearSiteMap: clears all the Subgurim SiteMap database (be careful with this methood ;) )
  • showSiteMap: returns a string with the final SiteMap XML file.

Here we place a C# example of code that use this method's: 

using Subgurim.Controles.SSM;
...
SubgurimSiteMapBLL.addSiteMap("http://www.mydomain.com/myfolder/mypage.aspx");
//SubgurimSiteMapBLL.deleteSiteMap("http://www.mydomain.com/myfolder/mypage.aspx");
//SubgurimSiteMapBLL.clearSiteMap();
Response.Clear();
Response.ContentType = "text/xml";
Response.Flush();
Response.Write(SubgurimSiteMapBLL.showSiteMap());
Response.End();

 

Last edited May 10, 2012 at 9:08 AM by lorenzobattaglia, version 10

Comments

lianaent Jun 29, 2013 at 10:58 PM 
In fact, when I put it live it totally crashes m web site. Nice little utility otherwise...

lianaent Jun 29, 2013 at 7:01 PM 
This seems quite a bit worse than useless. I have the same problem as nuronce - you have to troll all your hundreds/thousands of pages before they show up. What's worse is it adds the sites I labeled as "forbidden" and doesn't create something like "sitemap.xml" in the root folder as I requested. Instead it only gives subgurim.xml which is not what I asked for. It doesn't create "sitemap.aspx" either, although I'm not sure why you'd want that.

nuronce Apr 9, 2013 at 4:23 PM 
I installed it but it seems to ONLY generate items for pages that have been visited since the DLL / web.config is in place. I don't see it walking the directories.