2012-01-06 56 views
0

我能以这种格式生成网站地图:如何捕捉网站地图构造

<?xml version="1.0" encoding="UTF-8"?> 
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> 
    <url> 
    <loc>http://www.Shree/AboutMe.aspx</loc> 
    <lastmod>0001-01-01T12:00:00+00:00</lastmod> 
    <changefreq>Always</changefreq> 
    <priority>0.0</priority> 
    </url> 
    <url> 
    <loc>http://www.Shree/Home.aspx</loc> 
    <lastmod>0001-01-01T12:00:00+00:00</lastmod> 
    <changefreq>Always</changefreq> 
    <priority>0.0</priority> 
    </url> 
</urlset> 

,我尝试提交它Google.In提交按钮

 System.Net.WebRequest reqGoogle = System.Net.WebRequest.Create("http://www.google.com/webmasters/tools/ping?sitemap=" + HttpUtility.UrlEncode("http://www.Shree/SiteMap/sitemap.xml")); 
reqGoogle.GetResponse(); 

我要顺应和抓GoogleResponse和显示label。我尝试:

label1.text= reqGoogle.GetResponse().ToString(); 

其退货System.Net.HttpWebResponse。这不是我想要的吗?google在提交后发送任何回应sitemap。我应该能够在label中捕捉并显示吗?谢谢。

//当Debug时代码没有任何错误。

+0

@Antonia NOP想使自己的网站地图提交:)。任何想法?如何捕捉response.Thanks。 – 2012-01-06 08:32:57

+1

是的,我看到并删除了问题,因为问题很清楚你想做什么,但是在克罗地亚是一个早晨和假期,所以我有点困了;) – 2012-01-06 08:57:22

回答

0

Google只返回HTTP代码200,如Submiting sitemaps页所述。

所以你应该做这样的事情

HttpWebResponse resp = (HttpWebResponse)reqGoogle.GetResponse(); 
label1.Text = resp.StatusCode == HttpStatusCode.OK ? "Sitemap received" : "Error submiting sitemap"; 
+0

非常感谢。我得到了我想要的东西。非常感谢。 – 2012-01-06 09:47:10

相关问题