Generate sitemap on the fly

Question :

Generate sitemap on the fly,

Answer :

I’m trying to generate a sitemap.xml on the fly for a particular website.

I found a couple solutions:


Chinookwebs is working great but seems a bit inactive right now and it’s impossible to personalize the “priority” and the “changefreq” tags of each and every page, they all inherit the same value from the config file.

What solutions do you guys use?


Usually you’ll use an  for this. Given a request for…


…your handler will respond with a formatted XML sitemap. Whether that sitemap is generated on the fly, from a database, or some other method is up to the HTTP Handler implementation.

Read More  User Control Property Designer Properties

Here’s roughly what it would look like:

void IHttpHandler.ProcessRequest(HttpContext context)  {      //      // Important to return qualified XML (text/xml) for sitemaps      //      context.Response.ClearHeaders();      context.Response.ClearContent();      context.Response.ContentType = "text/xml";      //      // Create an XML writer      //      XmlTextWriter writer = new XmlTextWriter(context.Response.Output);      writer.WriteStartDocument();      writer.WriteStartElement("urlset", "");      //      // Now add entries for individual pages..      //      writer.WriteStartElement("url");      writer.WriteElementString("loc", "");      // use W3 date format..      writer.WriteElementString("lastmod", postDate.ToString("yyyy-MM-dd"));      writer.WriteElementString("changefreq", "daily");      writer.WriteElementString("priority", "1.0");      writer.WriteEndElement();      //      // Close everything out and go home.      //      result.WriteEndElement();      result.WriteEndDocument();      writer.Flush();  }  

This code can be improved but that’s the basic idea.

Read More  Document or RPC based web services

That’s the answer Generate sitemap on the fly, Hope this helps those looking for an answer. Then we suggest to do a search for the next question and find the answer only on our site.

Disclaimer :

The answers provided above are only to be used to guide the learning process. The questions above are open-ended questions, meaning that many answers are not fixed as above. I hope this article can be useful, Thank you