HTTPWebResponse + StreamReader Very Slow

HttpWebRequest may be taking a while to detect your proxy settings. Try adding this to your application config: <system.net> <defaultProxy enabled=”false”> <proxy/> <bypasslist/> <module/> </defaultProxy> </system.net> You might also see a slight performance gain from buffering your reads to reduce the number of calls made to the underlying operating system socket: using (BufferedStream buffer = … Read more

GetResponseAsync does not accept cancellationToken

Something like this should work (untested): public static class Extensions { public static async Task<HttpWebResponse> GetResponseAsync(this HttpWebRequest request, CancellationToken ct) { using (ct.Register(() => request.Abort(), useSynchronizationContext: false)) { var response = await request.GetResponseAsync(); ct.ThrowIfCancellationRequested(); return (HttpWebResponse)response; } } } In theory, if cancellation is requested on ct and request.Abort is invoked, await request.GetResponseAsync() should throw … Read more

Get HTTP requests and responses made using HttpWebRequest/HttpWebResponse to show in Fiddler

The Fiddler FAQ gives the answer to this. You essentially route your HTTP traffic through Fiddler (i.e. Use Fiddler as a proxy). Here’s some links that will help: Fiddler Web Debugging – Configuring Clients Which in turn links to here: Take the Burden Off Users with Automatic Configuration in .NET You can achieve this via … Read more

Uses of content-disposition in an HTTP response header

Note that RFC 6266 supersedes the RFCs referenced below. Section 7 outlines some of the related security concerns. The authority on the content-disposition header is RFC 1806 and RFC 2183. People have also devised content-disposition hacking. It is important to note that the content-disposition header is not part of the HTTP 1.1 standard. The HTTP … Read more

Parse value from http web response stream

It is easy using Json.Net. Just declare your concrete classes and then deserialize. var root = JsonConvert.DeserializeObject<RootObject>(yourJsonString); foreach (var item in root.TotalUsersCount) { Console.WriteLine(item.AccountStatus); } var allusers = root.TotalUsersCount.Sum(u => u.TotalUsers); public class TotalUsersCount { public int AccountStatus { get; set; } public int TotalUsers { get; set; } public int MemberUsers { get; set; … Read more