HttpWebRequest Help

Please support our C# advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Apr 2008
Posts: 27
Reputation: DevC++4.9.9.2 is an unknown quantity at this point 
Solved Threads: 1
DevC++4.9.9.2 DevC++4.9.9.2 is offline Offline
Light Poster

HttpWebRequest Help

 
0
  #1
Jun 10th, 2009
Hello, I am trying to create a program to stress test a website, I am using a counter on the page to see how many "clicks" have been made to this website.

Currently i am using HttpWebRequest to make a connection to the site and then end it. However this is not registering on the page counter. Any ideas how to make this register?

  1. private uint HitWebsite(string website)
  2. {
  3. HttpWebRequest request = (HttpWebRequest)
  4. WebRequest.Create(website);
  5. HttpWebResponse response = (HttpWebResponse)
  6. request.GetResponse();
  7. response.Close();
  8. return 1;
  9. }

This code is being called many times. Any ideas on how to make this work and/or what i might be doing wrong are welcome : )
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 3,242
Reputation: sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of 
Solved Threads: 577
Sponsor
sknake's Avatar
sknake sknake is offline Offline
.NET Enthusiast

Re: HttpWebRequest Help

 
0
  #2
Jun 10th, 2009
The page counter is probably an embedded link or javascript. It depends on the page counter but you will likely need to do another get with the referring URL of your site. What hit counter are you using?
Scott Knake
Custom Software Development
Apex Software, Inc.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 2,638
Reputation: adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of 
Solved Threads: 472
Moderator
adatapost's Avatar
adatapost adatapost is offline Offline
Posting Maven

Re: HttpWebRequest Help

 
-2
  #3
Jun 10th, 2009
You need a Web Service (develop or buy) and JavaScript code to invoke Web service method.
Failure is not fatal, but failure to change might be. - John Wooden
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 27
Reputation: DevC++4.9.9.2 is an unknown quantity at this point 
Solved Threads: 1
DevC++4.9.9.2 DevC++4.9.9.2 is offline Offline
Light Poster

Re: HttpWebRequest Help

 
0
  #4
Jun 10th, 2009
Originally Posted by sknake View Post
The page counter is probably an embedded link or javascript. It depends on the page counter but you will likely need to do another get with the referring URL of your site. What hit counter are you using?
Thanks for your reply,

I am using two counters
The first is java, The second is HTML
On this test page:
http://www.funkohland.com/test/hitcounter

could you give me an example of "another get with the referring URL of your site"?

Thank you in advance
Last edited by DevC++4.9.9.2; Jun 10th, 2009 at 9:31 pm.
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 3,242
Reputation: sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of 
Solved Threads: 577
Sponsor
sknake's Avatar
sknake sknake is offline Offline
.NET Enthusiast

Re: HttpWebRequest Help

 
1
  #5
Jun 10th, 2009
Here you go:
  1. private void simpleButton1_Click(object sender, EventArgs e)
  2. {
  3. const string site = @"http://www.funkohland.com/test/hitcounter";
  4. GetPage(site);
  5. GetPage(@"http://simplehitcounter.com/hit.asp?uid=409840&f=255&b=0", site);
  6. GetPage(@"http://www.wundercounter.com/cgi-bin/stats/image.cgi?user=MasterDebater&page=www.funkohland.com/test/hitcounter&bgcolour=white&fontcolour=black&digits=5", site);
  7. }
  8. private static void GetPage(string URL)
  9. {
  10. GetPage(URL, string.Empty);
  11. }
  12. private static void GetPage(string URL, string Referrer)
  13. {
  14. HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(URL);
  15. req.Method = "GET";
  16. req.Referer = Referrer;
  17.  
  18. HttpWebResponse objResponse = (HttpWebResponse)req.GetResponse();
  19. using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
  20. {
  21. sr.ReadToEnd();
  22. sr.Close();
  23. }
  24. }

Its your job to code in the asynchronous web requests to truly load test. If you use a single thread you will not accurately simulate a load. On another note I took the links from your pages' source good. If you're wanting to automate a task like this then you're looking in to link scraping and that is another topic (and very involved at that).

Good luck
Scott Knake
Custom Software Development
Apex Software, Inc.
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 27
Reputation: DevC++4.9.9.2 is an unknown quantity at this point 
Solved Threads: 1
DevC++4.9.9.2 DevC++4.9.9.2 is offline Offline
Light Poster

Re: HttpWebRequest Help

 
0
  #6
Jun 10th, 2009
Its your job to code in the asynchronous web requests to truly load test. If you use a single thread you will not accurately simulate a load. On another note I took the links from your pages' source good. If you're wanting to automate a task like this then you're looking in to link scraping and that is another topic (and very involved at that).

Good luck

Thank you very much, I am excited to start working off your example!
Last edited by DevC++4.9.9.2; Jun 10th, 2009 at 10:01 pm.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC