Wednesday 15 February 2012

c# - Register Custom Protocol with WebRequest -


I'm reaching a web server, which requires a custom protocol instead of http in the URL. I have tried to register my protocol, but there is no documentation to work on it. Web servers work on standard HTTP responses, but if the request is not included in the custom instead of http: //: // It will not work. I just want to use WebRequest built-in functionality because it is eventually HTTP, however, Need a way to submit a request with your custom protocol URL. I register it like this:

  WebRequest.RegisterPrefix ("custom", new custombighter creator ());   

But then, when I go to create a WebRest, when it returns my custom class after this code:

  Uri Uri = new Uri ("custom: //192.168.0.122: 94,934 / resources"); System.Net.WebRequest request = WebRequest.Create (uri);   

Debugger says that is actually my custom class, but then I get this exception:

  System.NotImplementedException was unrestricted HResult = -2147467263 Message = This method is not implemented by this class on Source = System StackTrace: System.Net.WebRequest.GetResponse () ... ...   

When I enter my URL without entering a sub-id I try to pass in WebRequest.Create (), I get this exception:

  System.NotSupportedException was unmanaged HResult = -2146233067 Message = URI prefix Anyta is not. Source = System StackTrace: URI Request on System.Net.WebRequest.Create (SystemNet.WebRequest.Create, URI, Boolean UsageUuribase) ... URI RequestYour ...   

Any ideas How could I have to do this work?

This does not seem possible, or will reach the level of complexity to re-apply to the WebRavate Scratches from HTTP for

I recommend you create a TCP relay, which you will connect to using WebRequest [, relay will be closed at TCP Socket 192.168.0.122:94934.

With the relay, you use normal and simplified WebRezest objects. If this console / webform is for Ideaton, then the relay can be started on another thread (or can be started with asynchronous), when the application starts.

No comments:

Post a Comment