0

I've been searching for this problem but non was identical to my case.

I have the following controller:

 public HttpResponseMessage GetMyService(int aType, [FromUri] string streamURL)

streamURL is a parameter that gets a full URL sent by the client.

The client calls the service like that: http://www.myservice.com/.../GetMyService/?aType=1&streamURL=http://www.client.com/?p1=100&p2=200

The problem is that at then end, I get the [FromUri] string streamURL parameter as http://www.client.com/?p1=100 without the &p2=200

This is known and reasonable, but I cannot place any encoding/decoding functionality as the URL is cut at the very beginning.

Any help would be appreciated..

THX

3
  • The client should encode the URL before it gets sent to your service where it can then be decoded and used as appropriate. I don't think there's much your service can do since as it stands it can't tell the difference between a new querystring parameter and the continuation of the URL sent from the client. Commented May 14, 2017 at 11:59
  • The streamURL value needs to be Url Encoded by the calling client Commented May 14, 2017 at 12:06
  • How is the client making the request? What is the client? provide a minimal reproducible example that can be used to reproduce the problem. Commented May 14, 2017 at 12:10

1 Answer 1

3

The client should properly URL encode the value of the streamURL query string parameter when making the request in order to conform to the HTTP protocol specification:

http://www.myservice.com/.../GetMyService/?aType=1&streamURL=http%3A%2F%2Fwww.client.com%2F%3Fp1%3D100%26p2%3D200

So basically there's nothing you could do on the server side, you should fix the client.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.