<%@ WebHandler Language="C#" Class="SiteMap" %> using System; using System.Web; using System.Xml; using Atiba.Web; using Atiba.Web.Portal; public class SiteMap : IHttpHandler { public void ProcessRequest (HttpContext context) { context.Response.ContentType = "text/xml"; using (XmlWriter writer = XmlWriter.Create(context.Response.OutputStream)) { WriteSiteMap(writer, context); } } private void WriteSiteMap(XmlWriter writer, HttpContext context) { writer.WriteStartElement("urlset", "http://www.google.com/schemas/sitemap/0.84"); WriteSiteMapNode(SiteProvider.SiteMapProvider.RootNode, writer, context); writer.WriteEndElement(); } private void WriteSiteMapNode(SiteMapNode node, XmlWriter writer, HttpContext context) { foreach (SiteMapNode childNode in node.ChildNodes) { WriteSiteMapNode(childNode, writer, context); } string showInSiteMap = node["showInSiteMap"]; if(!string.IsNullOrEmpty(showInSiteMap) && showInSiteMap != "1") { return; } writer.WriteStartElement("url"); writer.WriteElementString("loc", "http://" + context.Request.Url.Host + node.Url); writer.WriteElementString("changefreq", "daily"); writer.WriteEndElement(); } public bool IsReusable { get { return false; } } }