In my last post, I talked about how WCF actually can handle a lot more than basic web service communication. Today, I’m going to take that a little further, by showing you how you could build a very basic web server on top of WCF. If you are familiar with ASP.NET, you have probably heard of a little class called IRequestHandler. In ASP.NET, if you wanted to create a handler that simply streamed a file from disk, you might write a little code like this:
view plaincopy to clipboardprint? 1. public class FileRequestHandler : IHttpHandler
2. {
3. #region IHttpHandler Members
4.
5. public bool IsReusable
6. {
7. get { return false; }
8. }
9.
10. public void ProcessRequest(HttpContext context)
11. {
12. context.Response.WriteFile(context.Request.PhysicalPath);
13. }
14.
15.
view plaincopy to clipboardprint? 1. public class FileRequestHandler : IHttpHandler
2. {
3. #region IHttpHandler Members
4.
5. public bool IsReusable
6. {
7. get { return false; }
8. }
9.
10. public void ProcessRequest(HttpContext context)
11. {
12. context.Response.WriteFile(context.Request.PhysicalPath);
13. }
14.
15.