- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当我创建带有点段的 uri 时:
var uri = new Uri("http://localhost/../../g");
uri 类删除了 ../
段,结果 uri 变为:
http://localhost/g
当点之前有路径时:
var uri = new Uri("http://localhost/a/b/c/./../../g");
// Result: http://localhost/a/g
看起来 Uri
类在 the standart 之后(第 33 页 - remove_dot_segments),但是有什么方法可以保留点段而不是使用 Uri 自动解析目标 uri类(class)?还是我需要自定义实现?
最佳答案
如果您使用的是 HTTP,则不会,如果您使用 Uri 类,它总是会转义它们。它对以下所有内容进行转义:file、http、https、net.pipe 和 net.tcp
如果您使用的是 ftp
之类的东西,那么它不会转义,但听起来这不是您的选择。
来自 MSDN's documentation :
As part of canonicalization in the constructor for some schemes, escaped representations are compacted. The schemes for which URI will compact escaped sequences include the following: file, http, https, net.pipe, and net.tcp. For all other schemes, escaped sequences are not compacted. For example: if you percent encode the two dots ".." as "%2E%2E" then the URI constructor will compact this sequence for some schemes. For example, the following code sample shows a URI constructor for the http scheme.
关于c# - 有没有办法使用 Uri 类在 url 中保留点段?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39835099/
我是一名优秀的程序员,十分优秀!