开发者

Passing network path in URL

开发者 https://www.devze.com 2022-12-19 21:15 出处:网络
I am creating a WCF Service with a method [OperationContract] [WebGet(UriTemplate = \"acl/f={fullFileName}\")]

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 th开发者_如何学编程e URI.

Any thoughts on this will be greatly appreciated.

Thanks, beezlerco at hotmail...


You need to encode the slashes, colons, and technically the periods as well.

  • \ should be %5C
  • / should be %2F
  • . should be %2E
  • : should be %3A

for most other special characters see http://www.asciitable.com/ and use '%' plus the hex column on that table.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号