Enabling Tracing for System.Net

In whidbey, System.Net has a cool retail tracing implementation. It writes most calls made to public API’s to a TraceListener. You can setup your own tracelisteners, or use the config file to setup a default listener. This facility is very useful in debugging problems with applications. Here is the example config file which enables Verbose…

0

HttpWebRequest and Host Headers

A user posted on the newsgroups asking about how to set Host headers in HttpWebRequest. HttpWebRequest does not allow the host header to be set by the user. It is set automatically from the URI supplied to HttpWebRequest constructor. However, it turns out that there is a roundabout way to accomplish this. This is shown…

1

Forcing reuse of connections when doing Windows Authentication

When doing authentication, HttpWebRequest manages connections differently, depending on the authentication mode being used. If it uses Windows Integrated Authentication, it will close the connection after every request completes. The reasons for this are complex, and I wont go into them at this point. However, there are cases where you dont want this to happen….

0

Async Programming Model – Reloaded

This topic is about the asynchronous programming model, and how it is used when doing Networking.   Introduction to Asynchronous Programming   The DotNetFramework supports an asynchronous programming model that is uniform across all classes & features in the framework. What is cool about this model is that there is a uniform way of doing…

5

HttpWebRequest and PreAuthentication

The topic of this post is PreAuthentication. HTTP Webservers support multiple authentication options. On Windows, IIS supports Basic, NTLM, Digest, Negotiate (a.k.a Integrated Windows Authentication). Of these, Basic & Kerberos support PreAuthentication. “PreAuthentication” is sometimes misunderstood to mean “Send credentials on the very first request”. That is not the way it works. For Preauthenticate to work,…

0

Downloading content from the web using different encodings

The other day, somebody asked me: How do I download a webpage, or other content from a webserver, where the content is stored using a specific encoding ? They want to do this using for eg: System.Net.HttpWebRequest Why is this necessary ? Well, for starters, webservers around the world store their content in various encodings….

10

A tale of threads

Today’s lesson is about thread interaction between Asp.Net and the HttpWebRequest object of the System.Net namespace. The CLR provides a threadpool. This facility provides threads for normal work ( worker threads ), I/O work ( I/O threads) and Timer Threads. Normally, the limit of threads for managed processes is set as follows: WorkerThreads: 25 per…

1

HttpWebRequest and Connections

The .NET Framework has a HttpWebRequest object in the System.Net namespace. This object allows you to talk to HTTP Servers. Usually, people forget that the underlying connection created by the request is not freed up,unless you call Close() on the response. So, you hit the connection limit, and no more webrequests will go through. This…

8