Click here to Skip to main content
15,880,972 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to make webrequest from the following path. But everytime I request it returns the contents of the firtst page not the second one.

C#
public static string FetchWebpageSourceContent()
        {
          string _path="http://www.amazon.com/s/ref=sr_nr_i_0?rh=k%3Ajewelry+deals%2Ci%3Ajewelry&keywords=jewelry+deals&ie=UTF8&qid=1341384452#/ref=sr_pg_2?rh=k%3Ajewelry+deals%2Cn%3A3367581&page=2" 
 
          try
            {
                var req = HttpWebRequest.Create(_path);
                var response = req.GetResponse();

                return new System.IO.StreamReader(response.GetResponseStream()).ReadToEnd();
            }
            catch (Exception ex)
            {
                return String.Empty;
            }
        }
Posted
Updated 5-Jul-12 2:06am
v2

1 solution

I will check it with another URL, and it's working file with query string for another page. and it's working fine. there is no bug or any error in your code, ithink that url is have something which will redirect it to first page autometically.

the second url working file with 2 page selection.

C#
public static string FetchWebpageSourceContent()
        {
            string _path = "http://www.amazon.com/s/ref=sr_nr_i_0?rh=k%3Ajewelry+deals%2Ci%3Ajewelry&keywords=jewelry+deals&ie=UTF8&qid=1341384452#/ref=sr_pg_2?rh=k%3Ajewelry+deals%2Cn%3A3367581&page=2";
            string _path2 = "http://www.codeproject.com/script/Answers/List.aspx?tab=unanswered&pgnum=2";
          try
            {
                var req = HttpWebRequest.Create(_path2);
                var response = req.GetResponse();

                return new System.IO.StreamReader(response.GetResponseStream()).ReadToEnd();
            }
            catch (Exception ex)
            {
                return String.Empty;
            }
        }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900