Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Usually you'll use an <a href="http://www.google.com/search?q=HTTPHandler+ASP.NET&amp;spell=1" rel="noreferrer">HTTP Handler</a> for this. Given a request for...</p> <blockquote> <p><a href="http://www.yoursite.com/sitemap.axd" rel="noreferrer">http://www.yoursite.com/sitemap.axd</a></p> </blockquote> <p>...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.</p> <p>Here's roughly what it would look like:</p> <pre><code>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", "http://www.sitemaps.org/schemas/sitemap/0.9"); // // Now add entries for individual pages.. // writer.WriteStartElement("url"); writer.WriteElementString("loc", "http://www.codingthewheel.com"); // 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(); } </code></pre> <p>This code can be improved but that's the basic idea.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload