How to: Register a Custom Protocol Using WebRequest

This example shows how to register a protocol specific classthat is defined elsewhere. In this example, CustomWebRequestCreator is the user-implemented object that implements the Create method that returns the CustomWebRequest object. The code example assumes that you have written the CustomWebRequest code that implements the custom protocol.

WebRequest.RegisterPrefix("custom", new CustomWebRequestCreator());
WebRequest req = WebRequest.Create("custom://");

This example requires:

References to the System.Net namespace.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
© 2015 Microsoft