How to get status code of a POST with Asp.Net HttpWebRequest

I'm trying to ping Google when my web site's sitemap is updated but I need to know which status code does Google or any other service returns. My code is below:

HttpWebRequest rqst = (HttpWebRequest)WebRequest.Create("");
rqst.Method = "POST";
rqst.ContentType = "text/xml";
rqst.ContentLength = 0;
rqst.Timeout = 3000;



You need to use the response - assign it to a HttpWebResponse variable:

HttpWebResponse resp = (HttpWebResponse)rqst.GetResponse();
HttpStatusCode respStatusCode = resp.StatusCode;

The HttpStatusCode enumeration will tell you what status code was returned.

Try HttpWebResponse.StatusCode out

Need Your Help

Code that Builds in Visual Studio Won't Build in TFS

c# tfs msbuild visual-studio-2015

I have two extension methods defined in a C# class. When I compile code that uses these extension methods in Visual Studio 2015, they compile correctly. When I run the same code on an on-premises T...

Columns names from entity using LINQ

linq entity

I was able to get the columns names by using this: