C#Ashx谷歌xml站点地图生成错误
我正在使用ashx为Google提供我的网站站点地图。直到最近我才完美地工作。
在http://www.naughtyfancydress.com/sitemap.ashx上请求Google中的站点地图时,我得到:
XML解析错误:格式不正确
地点:http://naughtyfancydress.com/sitemap.ashx
第1行,第1列:`I %& /m {J
我在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的链接。
没有找到相关结果
已邀请:
1 个回复
孝铜差