I'm trying to send a request to a web service that requires certain . characters in the request URI to be percent-encoded as %2e. I'm having trouble sending a request from .NET, because when I construct the Uri instance it replaces the %2e characters with . characters. How can I work around this issue to send the web request in the form required by the service?
Edit: Here is how I'm constructing the request:
Uri uri = ...;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
request.Method = "GET";
request.Accept = "application/json";
request.UserAgent = "MyUserAgent";
I have attempted the following:
- Constructing the
Uriinstance usingUriTemplate.BindByName Constructing the
Uriinstance, then usingUriBuilderto try to insert the%2echaracters.Uri uri = "..."; UriBuilder builder = new UriBuilder(uri); builder.Path = builder.Path.Replace(".", "%2e"); uri = builder.Uri;Constructing the
Uriwhile setting thedontEscapeconstructor argument totrue.