在 URL 中传递网络路径
我正在使用方法 fullFileName 创建 WCF 服务,
[OperationContract]
[WebGet(UriTemplate = "acl/f={fullFileName}")]
string GetACL(string fullFileName);
fullFileName 是网络文件或主机上文件的完整路径。
主机是一个具有 webHttpBinding 和行为配置的 Windows 服务。 我想使用类似
http://localhost/webservice/acl/f=[my network path here]
我尝试过的东西从浏览器中调用它.../acl/f=file://\server\share\file.ext .../acl/f=file://c:\file.ext
在浏览器中,我收到“未找到端点”。
我知道这是有效的,因为我可以调用 .../acl/f=file.txt 并且从我的服务中得到正确的响应,表明未找到该文件。因此,当我不在 URI 中使用任何斜杠时,该方法就会被正确调用。
对此的任何想法将不胜感激。
谢谢, beezlerco 在 hotmail...
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...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要对斜杠、冒号以及技术上的句点进行编码。
:对于大多数其他特殊字符 请参阅 http://www.asciitable.com/ 并使用“%”加上该表上的十六进制列。
You need to encode the slashes, colons, and technically the periods as well.
for most other special characters see http://www.asciitable.com/ and use '%' plus the hex column on that table.
我相信 HttpUtility.UrlEncode 就是您正在寻找的内容。
(有关详细说明,请参阅使用 HttpUtility.UrlEncode 对查询字符串进行编码)
I believe HttpUtility.UrlEncode is what you are looking for.
(For a detailed description, see Using HttpUtility.UrlEncode to Encode your QueryStrings)