2010-12-19 4 views
0

Google 용 웹 사이트 Sitemap을 제공하기 위해 ashx를 사용하고 있습니다. 그것까지 모두 내가 최근까지 완벽하게 작동했습니다. http://www.naughtyfancydress.com/sitemap.ashx 구글에 사이트 맵을 요구하는 경우C# Ashx Google xml 사이트 맵 생성 오류

내가 얻을 : 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와의 링크를 확인하십시오.

+0

URL : http : //www.naughtyfancydress.com/sitemap.ashx로 이동하면 응답이 없으며 문제가 될 수 있습니다. URL을 찾아보고 실제로 XML 출력을 받고 있는지 확인 했습니까? – Chandu

+0

음, 크롬을 검색하면 아무 것도 얻을 수 없지만 크롬 문제라고 생각합니다. 당신이 IE 나 Firefox에서 시도한다면 위에서 언급 한 오류가 발생합니다 : XML 구문 분석 오류 : 형식이 올바르지 않음 위치 : http://naughtyfancydress.com/sitemap.ashx 행 번호 1, 열 1 :'I % % &/m {J – asn1981

+0

추가 조사가 끝나면 위의 정확한 코드가 내 .net 3.5 프로젝트에서 작동합니다. 그것은 넷 4로 작성된 새로운 웹 사이트에서 작업하는 것을 멈췄습니다. 나는 이것이 이것과 관련이 있다고 생각하지만 문제를 해결하기 위해 무엇을해야합니까? – asn1981

답변

0

그 밖의 사람들은 Global.asax에서 Application_PreRequestHandlerExecute 메서드를 사용하여 내 콘텐츠를 gzip '했습니다.

위 내용이 명시 되었더라도 콘텐츠 인코딩이 utf-8에서 gzip으로 변경됩니다. 그게 바로 문제이며, 사이트 맵 처리기가 gzip으로 콘텐츠를 보내지 않도록해야합니다.

관련 문제