0

I just wanted to fetch some useful data from a webpage. This webpage is using asp.net with UpdatePanel. When I do it manually, it takes me to follow to steps to get the required data. In the first step, I fill a TextBox with a search value and click a button. Then the webpage displays result with some values binded in it within a GridView. This GridView contains a View LinkButton that when clicked, displays the complete required information. I need to store this data for some other project. The website does not provide any kind of web service to do this and fetching this data is very important for my upcoming project otherwise the project will be cancelled.

I have tried various example that I have found while searching on StackOverflow, but it is returning me the first page with blank response data.

    using (var wb = new WebClient())
    {
        var data = new NameValueCollection();
        data["name"] = name;
        var response = wb.UploadValues(url, "POST", data);
        string value = ASCIIEncoding.ASCII.GetString(response);
        lblResponse.Text = value;
    }

Please guide me to do this important task.

vivek
  • 1,595
  • 2
  • 18
  • 35

1 Answers1

0

I would recommend using a tool like Fiddler to capture the entire requests that are caused by your manual actions, and then send them using WebClient.

Also, That way you can capture the requests of WebClient and compare them with the original.

Community
  • 1
  • 1
argaz
  • 1,458
  • 10
  • 15
  • i am using firebug to get the entire request and response, but unable to understand it completely. There is a lot of text. What should i consider for working on this thing. As there is only one textbox in the webpage, i am passing only one value as postdata. Is there anything else that need to be posted as data? – vivek Jun 07 '13 at 16:49
  • Isn't there __ViewState hidden input (as it's ASP.NET)? Possibly there are headers that are needed to be set. If you have doubts you can always capture the requests that you programmatically make and compare them with the manual ones. – argaz Jun 07 '13 at 17:05
  • Yes, there is _ViewState hidden input field. Do i need to pass this information too as a parameter. – vivek Jun 07 '13 at 17:32
  • 1
    Probably you should, as ASP.NET relies on it. – argaz Jun 07 '13 at 18:26