943,788 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Marked Solved
  • Views: 2388
  • C# RSS
Jun 10th, 2009
0

HttpWebRequest Help

Expand Post »
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?

C# Syntax (Toggle Plain Text)
  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 : )
Similar Threads
Reputation Points: 10
Solved Threads: 1
Light Poster
DevC++4.9.9.2 is offline Offline
39 posts
since Apr 2008
Jun 10th, 2009
0

Re: HttpWebRequest Help

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?
Featured Poster
Reputation Points: 1749
Solved Threads: 735
Senior Poster
sknake is offline Offline
3,948 posts
since Feb 2009
Jun 10th, 2009
-1

Re: HttpWebRequest Help

You need a Web Service (develop or buy) and JavaScript code to invoke Web service method.
Moderator
Reputation Points: 2136
Solved Threads: 1228
Posting Genius
adatapost is offline Offline
6,527 posts
since Oct 2008
Jun 10th, 2009
0

Re: HttpWebRequest Help

Click to Expand / Collapse  Quote originally posted by sknake ...
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.
Reputation Points: 10
Solved Threads: 1
Light Poster
DevC++4.9.9.2 is offline Offline
39 posts
since Apr 2008
Jun 10th, 2009
1

Re: HttpWebRequest Help

Here you go:
c# Syntax (Toggle Plain Text)
  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
Featured Poster
Reputation Points: 1749
Solved Threads: 735
Senior Poster
sknake is offline Offline
3,948 posts
since Feb 2009
Jun 10th, 2009
0

Re: HttpWebRequest Help

Quote ...
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.
Reputation Points: 10
Solved Threads: 1
Light Poster
DevC++4.9.9.2 is offline Offline
39 posts
since Apr 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: WPF MediaElement displaying Images or Video with transitions
Next Thread in C# Forum Timeline: Help with pattern matching





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC