Hi, I am trying to get the whole total page size using HttpWebRequest from image scripts etc. I need to calculate the total web page traffic if one user visits the page through a web browser. The length of the content brings me the length of the content in byte size. Actually the length of the document. But I also need to get all the traffic from images and scripts.
This is my code. Bye.
NetworkCredential cred = new NetworkCredential("username", "password"); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url); request.Proxy = new System.Net.WebProxy("proxy", true); request.Proxy.Credentials = cred; request.UserAgent = @"Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5"; using (HttpWebResponse requestresponse = (HttpWebResponse)request.GetResponse()) { Headers = requestresponse.Headers; Url = requestresponse.ResponseUri; int ContentLength; if (int.TryParse(response.Headers.Get("Content-Length"), out ContentLength)) {
In addition, the length of the contents of the header is not guaranteed that the server will respond to it.
Any suggestions?
source share