asp.net - RSS Feed URL 中的 & 符号

标签 asp.net

作为我们应用程序的一部分,用户可以将一些数据以 XML 形式保存在服务器上,这些数据将成为他们的 RSS 提要。

现在,用户创建的一些文件的文件名中包含 & ,如 BB&T_RSS.xml。

所以当用户将其指向 http://example.com/BB&T.xml 时,他们不会得到这个。

如何阻止这个?我尝试了 BB%26T.xml、BB&T.xml,但在 IE、Chrome 上没有成功

最佳答案

使用

%26

对于

&

http://example.com/BB%26T.xml ,

http://www.w3schools.com/tags/ref_urlencode.asp

然后使用

HttpServerUtility.UrlDecode Method

再次从url获取文件

URL encoding ensures that all browsers will correctly transmit text in URL strings. Characters such as a question mark (?), ampersand (&), slash mark (/), and spaces might be truncated or corrupted by some browsers. As a result, these characters must be encoded in tags or in query strings where the strings can be re-sent by a browser in a request string.

Many URL schemes reserve certain characters for a special meaning: their appearance in the scheme-specific part of the URL has a designated semantics. If the character corresponding to an octet is reserved in a scheme, the octet must be encoded. The characters ";", "/", "?", ":", "@", "=" and "&" are the characters which may be reserved for special meaning within a scheme. No other characters may be reserved within a scheme. (src)

关于asp.net - RSS Feed URL 中的 & 符号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4691263/

相关文章:

asp.net - 模拟:ASP.Net MVC Controller 操作与Web窗体

asp.net - 在 ASP.NET 中实现可编辑的 DropDownList

sql 中的 ASP.NET session 状态

asp.net - 如何在 ASP.NET MVC 中将子域重定向到 'area'?

c# - 拒绝输入重复字符的正则表达式

c# - 当我有 anchor 标记时 itextsharp "the document has no pages"错误

c# - asp net forms身份验证无法在同一服务器上同时登录两个应用程序

c# - 防止 ASP.Net AppDomain 卸载

asp.net 按钮事件未触发

asp.net - 从网页录制音频