As you may have read about by now, Google allows you to publish an XML site map that helps their Web crawlers find all the pages in your site. Newtonsoft was nice enough to publish an assembly that reads your ASP.NET sitemap and produces a Google sitemap for you. You only need to add one line of code to your web.config, which sets up an HttpHandler. Then you can point Google to the path specified in the handler, and you’re done. This allows you to maintain just the ASP.NET sitemap yet still take advantage of Google’s new service.
Setup of the Newtonsoft GoogleSitemap is easy, and is well documented on their site.
One gotcha to watch out for, though, occurs if you have Web applications in folders below the application you add this HttpHandler to. For instance, if you add the HttpHandler to your root web.config, as follows, it will be inherited by all the applications beyond the root.
<httpHandlers> <add verb="*" path="googlesitemap.axd" type="Newtonsoft.GoogleSitemap.GoogleSitemapHandler, Newtonsoft.GoogleSitemap"/> </httpHandlers>
So here you’re saying you can go to http://www.yourdomain.com/googlesitemap.axd to view your Google-ready Sitemap. But what if you have another application at http://www.yourdomain.com/subfolder/myapp.aspx? In the subsite the HttpHandler will be inherited, which means that http://www.yourdomain.com/subfolder/googlesitemap.axd should work too.
The problem is that the DLL you download from Newtonsoft is located in the root’s bin folder. When you visit http://www.yourdomain.com/googlesitemap.axd the DLL is found in the root’s bin folder. However, any applications below the root go looking for that assembly within their bin folder. When it can’t be found you’re stuck with the Could not load file or assembly 'Newtonsoft.GoogleSitemap' or one of its dependencies error.
The simplest way to fix this issue is to remove the httpHandler in the subsite. That can be accomplished by adding the following remove element in your subsite’s web.config, as shown below:
<httpHandlers> <remove verb="*" path="googlesitemap.axd" /> </httpHandlers>