c# - Would like to get http response results like Fiddler -


i'm trying same type of results fiddler gets when launch webpage app. below code i'm using , results i'm getting. i've used google.com example.

what need modify in code results want or need entirely different approach?

thanks help.

my code:

 // create httpwebrequest object         httpwebrequest objrequest = (httpwebrequest)webrequest.create("http://www.google.com");          // response object has header info, using getresponse method         var objresults = objrequest.getresponse();           // header count         int intcount = objresults.headers.count;          // loop through results object         (int = 0; < intcount; i++)         {             string strkey = objresults.headers.getkey(i);             string strvalue = objresults.headers.get(i);               lblresults.text += strkey + "<br />" + strvalue + "</br /><br />";         } 

my results:

cache-control private, max-age=0

content-type text/html; charset=iso-8859-1

date tue, 05 jun 2012 17:40:38 gmt

expires -1

set-cookie pref=id=526197b0260fd361:ff=0:tm=1338918038:lm=1338918038:s=gefqgwkuzupjlo3g; expires=thu, 05-jun-2014 17:40:38 gmt; path=/; domain=.google.com,nid=60=cjbpzme6utkf58ty7rysquftw6gnsqhz-uat_cff1auayffftjofqsiwt5osqkqqp5psiyoytbf_8osgh_xsk1yte7z834qwn0a4sw3ruvca9v3f_udyh4b4falofjbw; expires=wed, 05-dec-2012 17:40:38 gmt; path=/; domain=.google.com; httponly

p3p cp="this not p3p policy! see http://www.google.com/support/accounts/bin/answer.py?hl=en&answer=151657 more info."

server gws

x-xss-protection 1; mode=block

x-frame-options sameorigin

transfer-encoding chunked

========================= fiddler results:

result protocol host url body caching content-type process comments custom

1 304 http www.rolandgarros.com /images/misc/weather/p8.gif 0 max-age=700 expires: tue, 05 jun 2012 17:53:40 gmt image/gif firefox:5456
2 200 http www.google.com / 23,697 private, max-age=0 expires: -1 text/html; charset=utf-8 chrome:2324
3 304 http www.rolandgarros.com /images/misc/weather/p9.gif 0 max-age=700 expires: tue, 05 jun 2012 17:53:57 gmt image/gif firefox:5456
4 200 http tunnel translate.googleapis.com:443 0 chrome:2324
5 200 http www.google.com

the difference fiddler recording entire session, not single http request.

if user loads google.com, response typically html document contains images, script files, css files, etc. browser initiate new http request each 1 of resources. fiddler running, tracks each of http requests , spits out result code , other information session.

with c# code above, you're initiating single http request, have information single result.

you'd better off writing browser plugin. otherwise, you'd have parse html response , load other resources document well.

if do need c# code, parse document html agility pack , other resources within html simulate browser. there's embedded browsers, such awesomium, might helpful.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -