在 URL 中传递网络路径

发布于 2024-08-20 11:09:12 字数 624 浏览 3 评论 0原文

我正在使用方法 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

相思碎 2024-08-27 11:09:12

您需要对斜杠、冒号以及技术上的句点进行编码。

  • \ 应该是 %5C
  • / 应该是 %2F
  • 。应为 %2E
  • 应为 %3A

:对于大多数其他特殊字符 请参阅 http://www.asciitable.com/ 并使用“%”加上该表上的十六进制列。

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.

萌酱 2024-08-27 11:09:12

我相信 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)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文