BF2Statistics.ASP.StatsManager.ValidateASPService C# (CSharp) Method

ValidateASPService() public static method

Returns whether the specified URI is a valid, and available ASP Service
public static ValidateASPService ( string Url ) : void
Url string The root url to the ASP server. Dont include the /ASP/ path!
return void
        public static void ValidateASPService(string Url)
        {
            // Create the ASP request, and fetch the http response
            WebRequest Request = WebRequest.Create(new Uri(Url.TrimEnd('/') + "/ASP/getbackendinfo.aspx"));
            HttpWebResponse Response = (HttpWebResponse)Request.GetResponse();

            // Make sure that we connected successfully
            if (Response.StatusCode != HttpStatusCode.OK)
                throw new Exception("Unable to connect to the Gamespy ASP Webservice: " + Response.StatusDescription);

            // Parse the response message
            using (StreamReader Reader = new StreamReader(Response.GetResponseStream()))
            {
                // getunlockinfo.aspx always returns a valid response, starting with "O"
                string Lines = Reader.ReadToEnd().TrimStart();
                if (!Lines.StartsWith("O"))
                    throw new Exception("The ASP webserver didnt not respond with a proper ASP response!");
            }
        }