ashx を使用して、Google のウェブサイト サイトマップを配信しています。最近まで、そのすべてが完全に機能していました。
http://www.naughtyfancydress.com/sitemap.ashxで Google でサイトマップをリクエストすると、次のようになります: XML 解析エラー: 整形式ではありません 場所: http://naughtyfancydress.com/sitemap.ashx 行番号 1、列 1 :`I�%&/m�{J�</p>
ashx のコードを簡略化すると、次のようになります。
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();
解決方法に関するアイデアは大歓迎です。
編集: 上記のリンクを Chrome で確認しても何も表示されません。これは Chrome の問題だと思います。FireFox でリンクを確認してください。