public override void ProcessRequest(HttpContextBase context) { string name = context.Request.QueryString["name"]; SiteMapBase siteMap = this.GetSiteMap(name); if (siteMap != null && siteMap.GenerateSearchEngineMap) { HttpResponseBase response = context.Response; response.ContentType = "text/xml"; if (siteMap.Compress) { this.httpResponseCompressor.Compress(context); } using (StreamWriter streamWriter = new StreamWriter(response.OutputStream, Encoding.UTF8)) { using (XmlWriter xmlWriter = XmlWriter.Create(streamWriter, new XmlWriterSettings { Indent = false, Encoding = Encoding.UTF8 })) { this.WriteSiteMap(xmlWriter, siteMap, context); } } this.httpResponseCacher.Cache(context, TimeSpan.FromMinutes((double)siteMap.CacheDurationInMinutes)); } }
private void WriteSiteMap(XmlWriter writer, SiteMapBase siteMap, HttpContextBase httpContext) { string applicationRoot = httpContext.Request.ApplicationRoot(); writer.WriteStartDocument(); writer.WriteStartElement("urlset", "http://www.sitemaps.org/schemas/sitemap/0.9"); this.duplicateChecks.Clear(); this.WriteNode(writer, siteMap.RootNode, httpContext, applicationRoot); siteMap.RootNode.ChildNodes.Each(delegate(SiteMapNode node) { this.Iterate(writer, node, httpContext, applicationRoot); }); writer.WriteEndElement(); writer.WriteEndDocument(); }
public SiteMapBuilder(SiteMapBase siteMap) { this.siteMap = siteMap; this.siteMapNodeBuilder = new SiteMapNodeBuilder(this.siteMap.RootNode); }