1

在 C# 中我有 System.Security.SecurityElement.Escape(url),但在我的 BackgroundTask 中我无法访问它。我尝试:

url= url.Replace("&", "&amp;").Replace("<", "&lt;").Replace(">", "&gt;").Replace("\"", "&quot;").Replace("'", "&apos;");

但是这种方式非常非常无聊。有什么办法可以用本机方法做到这一点?就像我写的第一个一样。

UrlEncode 不适合我,只有我需要转义 url。

(我基于这个链接:http ://weblogs.sqlteam.com/mladenp/archive/2008/10/21/Different-ways-how-to-escape-an-XML-string-in-C.aspx )

任何想法?

提前致谢

4

0 回答 0