HttpWebRequest Problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mcco
    New Member
    • Jul 2008
    • 12

    HttpWebRequest Problem

    I have this code(in a separate thread if it helps):
    Code:
                // I know i don't store data from here. There is a reason for it.
                HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(mainUrl);
                req.CookieContainer = this.cookieJar;
                req.Method = "GET";
                req.GetResponse();
    
                // Another request
                HttpWebRequest gReq = (HttpWebRequest)HttpWebRequest.Create(secondaryUrl);
                gReq.CookieContainer = this.cookieJar;
                gReq.Method = "GET";
                gReq.UserAgent = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 7.1)";
                WebResponse res = (HttpWebResponse)gReq.GetResponse();
                StreamReader sr = new StreamReader(res.GetResponseStream());
                string response = sr.ReadToEnd();
                sr.Close();
                XmlDocument gPage = new XmlDocument();
                gPage.LoadXml(response);
    Now, at the last line (gPage.LoadXml( response)) it crashes with the next exception:
    Code:
    The remote server returned an error: (503) Server Unavailable
    I guess it's actully not in that line, but the problem is, that everything is available, I do have the needed response in the 'response' string..

    Please help me out.
    Thanks.
  • sashi
    Recognized Expert Top Contributor
    • Jun 2006
    • 1749

    #2
    Kindly refer to below attached link, hope it helps :)

    C# httpwebrequest server unavailable 503 problem

    Comment

    • mcco
      New Member
      • Jul 2008
      • 12

      #3
      Thanks for the help, but I found my problem.
      I am trying to load HTML document into XmlDocument and that is what causes the exception to be thrown.

      Comment

      Working...