void IHttpHandler.ProcessRequest(HttpContext context)
        {
            Guard.ArgumentIsNotNull(context, "context");
            var urlSet = _factory();
            var response = context.Response;

            var writer = new SitemapWriter(response.Output);
            writer.WriteSitemp(urlSet);

            response.ContentType = "application/xml";
            response.ContentEncoding = Encoding.UTF8;
            response.End();
        }
示例#2
0
        public override void ExecuteResult(ControllerContext context)
        {
            if (UrlSet == null)
            {
                throw new HttpException(404, "Sitemap was not found.");
            }

            var response = context.HttpContext.Response;
            var writer = new SitemapWriter(response.Output);
            writer.WriteSitemp(UrlSet);

            response.ContentType = "application/xml";
            response.ContentEncoding = Encoding.UTF8;
            response.End();
        }
        public void Given_few_urls()
        {
            var text = new StringWriter();
            var writer = new SitemapWriter(text);
            writer.WriteStartSitemap();
            writer.WriteUrl(new SitemapUrl
            {
                Location = "http://kievalt.net",
                LastModified = new DateTime(2012, 12, 12),
                Frequency = SitemapChangeFrequency.Daily,
                Priority = 0.7
            });
            writer.WriteEndSitemap();

            _result = XDocument.Parse(text.ToString());
        }