简体   繁体   中英

How to capture http request/response traffic results

I want to Capture Http Request/Response Traffic results(URL,Method,Type etc) with c# Windows Form App as manually.

An Example : Run ie explorer-> Tools -> F12 Developer Tools->Network Tab-Star Capture

How can I solve this problem. (Any use of the sdk. winpcap etc) How to trace a road?

Try the below:

...
HttpWebRequest request =(HttpWebRequest)WebRequest.Create(HttpUtility.UrlDecode(<url>));
...
try
{
     HttpWebResponse response =(HttpWebResponse)request.GetResponse();
     WebHeaderCollection headers = response.Headers;
     ...
}
catch(WebException exc) { "HTTP EXCEPTION: " + exc.Message +" " + exc.Status; }
catch(ProtocolViolationException exc) { exc.Message; }
catch(UriFormatException exc)         { exc.Message; }
catch(NotSupportedException exc)      { exc.Message; }
catch(IOException exc)                { exc.Message; }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM