Search code examples
c#wcfwebget

Passing network path in URL


I am creating a WCF Service with a method

[OperationContract]
[WebGet(UriTemplate = "acl/f={fullFileName}")]
string GetACL(string fullFileName);

fullFileName is a full path to a network file, or a file on the host.

The host is a Windows Service with webHttpBinding and behavior configuration. I want to call this from a browser using something like

http://localhost/webservice/acl/f=[my network path here]

I have tried .../acl/f=file://\server\share\file.ext .../acl/f=file://c:\file.ext

In the browser I receive "Endpoint not found".

I know this works because I can call .../acl/f=file.txt and I get back the proper response from my service indicating that the file was not found. So the method is getting called correctly when I don't use slashes of anysort in the URI.

Any thoughts on this will be greatly appreciated.

Thanks, beezlerco at hotmail...


Solution

  • I believe HttpUtility.UrlEncode is what you are looking for.
    (For a detailed description, see Using HttpUtility.UrlEncode to Encode your QueryStrings)