Tales from the Evil Empire

Bertrand Le Roy's blog

News

Ads Via DevMavens

ASP.NET AJAX UpdatePanel Control: Add Ajax interactivity to your ASP.NET 2.0 web pages


follow bleroy at http://twitter.com

Bertrand Le Roy




Add to Technorati Favorites

Blogs I read

My other stuff

Google Sitemaps for ASP.NET 2.0

Google has a little-known feature that enables web site authors to tell the search engine about the structure of their site. ASP.NET also has a way of representing the structure of the site in a map. ASP.NET SiteMaps can be exposed on the site using a Menu, TreeView or SiteMapPath control, but there is no built-in feature that exposes this information in the format that Google understands.

That's why I've developed a small handler that scans the ASP.NET SiteMap and formats it into the Google XML format for site maps. Once you've copied this handler into your site, just register it as your site map with Google from this page:
https://www.google.com/webmasters/sitemaps

I've also added a very simple control that displays the ASP.NET SiteMap in a very plain HTML form (using h1...h6 tags) that is likely to be well indexed by most search engines. The control's look can be very much improved on and customized but I'll leave that as an exercise for the reader.

The sample also comes with a sample site to demonstrate the use of the control and handler.

Download the project from here:
http://www.gotdotnet.com/codegallery/codegallery.aspx?id=237330e0-65c5-4ebb-b62b-e486dd598604

UPDATE: I updated the handler so that it can now use Google-specific attributes. You can now specify additional information such as the update frequency of each page directly in the ASP.NET SiteMap (version 1.1 of the handler).

UPDATE 2: This implementation is now obsolete. This feature is now part of the ASP.NET Futures release with a much more complete implementation. Check it out!
http://www.asp.net/downloads/futures/default.aspx?tabid=62

UPDATE 3: I've added back the source code as an attachment for this post, for reference purposes (but I encourage everyone to use the Futures version).

Attachment: GSiteMap1.1.zip
Posted: Dec 02 2005, 03:24 PM by Bertrand Le Roy | with 22 comment(s)
Filed under:

Comments

James Newton-King said:

I like your idea of trying to get the physical files last modified date to pass to Google.

I made my own version of this a couple of months ago but haven't had a website to release it on until recently.

Currently I'm letting the user set that sort of data in the sitemap file itself, but having the option to get the modified date directly from the file would be a nice option. Would you mind if I implemented it in what I made?

Here is a link to it (with the source) if you're curious:

http://www.newtonsoft.com/Products/GoogleSitemap/Default.aspx
# December 5, 2005 7:52 AM

Bertrand Le Roy said:

Feel free to modify what you want. I'll also add the possibility to add the Google-specific information directly in the site map file.
# December 5, 2005 2:41 PM

TrackBack said:

Scott about the handler and other SiteMap subjects
# December 5, 2005 4:44 PM

xgene said:

Downloaded this and it worked perfectly out the gate. Thanks much!
# November 1, 2006 3:42 PM

Ben said:

Got here from Sitefinity 3. Great add-on I am going to give this a try shortly.

# December 18, 2006 2:05 PM

Pete said:

Where to get this now as i cant find it on the got dot net site ?
# May 18, 2007 11:20 AM

Bertrand Le Roy said:

On GotDotNet, but the project has been obsoleted now that ASP.NET Futures have a similar, but much more complete feature.

# May 18, 2007 2:08 PM

Nic said:

I'm not awesome enough to convert this to VB. Is there potential for that?
# June 6, 2007 4:39 PM

Rafal said:

how can the google Sitemap be done with Futures? It seems it only suppoorts Windows Live. It also talks only about searching your site, not sitemap...

Does anybody has source code of this?

# August 1, 2007 3:14 AM

Bertrand Le Roy said:

Rafal: I confirm that the site map stuff is now in Futures.

quickstarts.asp.net/.../searchsitemaps.aspx

# August 2, 2007 3:19 AM

IgorV said:

"Feel free to modify what you want. I'll also add the possibility to add the Google-specific information directly in the site map file."

--

Where is the source? Links are broken on all sites that reference "Bertrand Le Roy's" handler. Futures have very poor documentation on this subject, I wasnt ablet o make it work.

# August 10, 2007 10:24 AM

Bertrand Le Roy said:

Igor: the documentation is way better than what was available for this version (i.e. this blog post), see previous comment for a link.

I can make the source code for this old project available here but I really encourage everyone to use the Futures version.

# August 11, 2007 3:19 AM

Steve Worthington said:

Hi there,

Informative blog and good examples thanks.

I hear what you are saying about using the Futures release and I have implemented using the Dynamic provider.

However I can find little documentation apart from the Quick starts. All of which seem to depend on a web.sitemap file being in existence, when really I want to create that on demand too.

So I have gone back to a custom handler for the google sitemap. Keen to hear if you know of any links to other implementations of the Dynamic provider.

Cheers,

Steve

# August 26, 2007 2:16 AM

Bertrand Le Roy said:

Steve: the Futures implementation can use any site map provider. Read this to learn how to implement your own:

msdn2.microsoft.com/.../system.web.sitemapprovider.aspx

# August 27, 2007 1:57 PM

Rich said:

Has anyone got a good example of the Futures implementation?

Documentation is a little scarce to say the least!

# November 13, 2007 7:05 AM

WTF said:

Update 1, Update 2, Update 3, sends you to a new page that says there is yet another update on another page....what's the deal....this page is a collosal waste of time

# March 8, 2008 12:08 AM

Bertrand Le Roy said:

The page that the updates links to points you to another download for a completely different feature, not for sitemaps.

# March 10, 2008 12:48 PM

Karen said:

Is there any way to get this anymore?  We are still using .net 2.0 so I can't use the futures implementation.

# April 1, 2009 10:58 AM

Bertrand Le Roy said:

@Karen: follow the link at the end of the post... Let me paste that here for you...

weblogs.asp.net/.../432188.ashx

# April 1, 2009 1:26 PM

will1968 said:

I have downloaded the latest zipped copy and got it working on my website. It looks good and google has accepted it.

Is there anything I should be worried about?

If not, thank you very much for some very useful code.

Will

# July 16, 2009 4:01 PM

Speedbird186 said:

Has this actually made it into 3.5 SP 1? The futures download doesn't exist anymore, but I can't seem to figure out how to find it if it is built into the latest Framework release?

# October 18, 2009 3:16 PM

Bertrand Le Roy said:

@speedbird186: it has not, but the source code is still available. It's attached to this post.

# October 18, 2009 3:43 PM
Leave a Comment

(required) 

(required) 

(optional)

(required)