tags:

views:

56

answers:

2

I have a web service with following operation contract and my service is hosted at http://localhost:9002/Service.svc/

[OperationContract]
[WebGet(UriTemplate = "/Files/{Filepath}")]
Stream DownloadFile(string Filepath);

This web service would let users download file, if the proper filepath is provided (assuming, I somehow find out that proper filepath).

Now, I can access this service from a browser by typing, http://localhost:9002/Service.svc/Files/(Filepath}

If {filepath} is some simple string, its not a problem, but I want to send the location of the file. Lets us say users want to download file C:\Test.mp3 on the server. But how can I pass C:\Test.mp3 as {Filepath}? I get an error when I type http://localhost:9002/Service.svc/Files/C:\Test.mp3 in the browser.

I am new to web services and find that this community is the quickest way to get answers to my questions.

got it working now. need to use HttpServerUtility.UrlTokenDecode() from System.web

+1  A: 

You cannot type special characters like ":" and "\" as part of a URL. They will need to be URL encoded.

John Saunders
+1  A: 

Sounds like you need to URL encode the string, then decode on the back end. Add System.Web to your project and use System.Web.HttpUtility.UrlEncode() then System.Web.HttpUtility.UrlDecode()

Serapth