fabri fresco

fabri fresco

  • NA
  • 8
  • 2.1k

Problem retrieving data with Webclient

Jul 3 2013 12:41 PM
Hi to everyone,i have a problem with my app that should retrive data from some websites.
I use this code to make a http POST request but i don't retrieve the correct data,probably because the website use iframes
The code I use is:

public static string HttpPost(string URI, string Parameters)
        {
            try
            {
            System.Net.WebRequest req = System.Net.WebRequest.Create(URI);
            req.ContentType = "application/x-www-form-urlencoded";
            req.Method = "POST"; 
            byte[] bytes = System.Text.Encoding.ASCII.GetBytes(Parameters);
            req.ContentLength = bytes.Length;
            System.IO.Stream os = req.GetRequestStream();
            os.Write(bytes, 0, bytes.Length);
            //os.Close();

            System.Net.WebResponse resp= req.GetResponse();
           
            if (resp == null) return null;
            System.IO.StreamReader sr = new System.IO.StreamReader(resp.GetResponseStream());
            return sr.ReadToEnd().Trim();
            }
            catch (Exception ex) { }
            return null;    
        }
-----------------------------------------

// naviga();
            Http.Post("http://89.137.253.14/Iast.php", new NameValueCollection() {
    { "imei", "013270000134001" }
});


The main website is :  http://sickw.com/index.html

As you can see if you make a direct GET or POST reuest using the url on the Form you receive a page error and that is what i receive using my app.
It's only a website example and if someone can help me i will happy to contribute with a donation too.
I need to receive the complete source page like using a browser

Thanks


Answers (1)