title: C# Ashx Google xml sitemap generation error
body: <p>I'm using a ashx to deliver my websites sitemap for Google. Its all worked perfectly until I recently.</p>
  
  <p>When requesting the sitemap in Google at <a href="http://www.naughtyfancydress.com/sitemap.ashx" rel="nofollow">http://www.naughtyfancydress.com/sitemap.ashx</a> I get:
      XML Parsing Error: not well-formed
      Location: <a href="http://naughtyfancydress.com/sitemap.ashx" rel="nofollow">http://naughtyfancydress.com/sitemap.ashx</a>
      Line Number 1, Column 1:`I�%&amp;/m�{J�</p>
  
  <p>My stripped down code in the ashx looks like:</p>
  
  <pre><code>context.Response.ClearHeaders();
  context.Response.ClearContent();
  context.Response.ContentType = "text/xml";
  context.Response.ContentEncoding = Encoding.UTF8;
  context.Response.Cache.SetExpires(DateTime.Now.AddSeconds(3600));
  context.Response.Cache.SetCacheability(HttpCacheability.Public);
  
  var writer = new XmlTextWriter(context.Response.OutputStream, Encoding.UTF8);
  writer.Formatting = Formatting.Indented;
  
  writer.WriteStartDocument();
  writer.WriteStartElement("urlset");
  writer.WriteAttributeString("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
  writer.WriteAttributeString("xsi:schemaLocation", "http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd");
  writer.WriteAttributeString("xmlns", "http://www.sitemaps.org/schemas/sitemap/0.9");
  
  writer.WriteStartElement("url");
  writer.WriteElementString("loc", "http://www.naughtyfancydress.com/");
  writer.WriteElementString("changefreq", "daily");
  writer.WriteElementString("priority", "1.0");
  writer.WriteEndElement();
  
  writer.WriteEndElement();
  writer.WriteEndDocument();
  writer.Flush();
  writer.Close();
  </code></pre>
  
  <p>Any ideas on how to resolve would be welcomed.</p>
  
  <p>EDIT: If you check the link above in Chrome nothing will display, I believe this is a Chrome issue, please check the link with FireFox.</p>