1

In C# I have System.Security.SecurityElement.Escape(url), but in my BackgroundTask I not access this. I try the:

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

but this way is very very boring. Have any way to do this with native methods? like the first I write.

UrlEncode not util for me, only I need escape url.

(I am based on this link: http://weblogs.sqlteam.com/mladenp/archive/2008/10/21/Different-ways-how-to-escape-an-XML-string-in-C.aspx )

Any idea?

Thanks in advance

fipcurren88
  • 701
  • 5
  • 26
  • Have you tried [Uri.EscapeDataString](https://msdn.microsoft.com/en-us/library/system.uri.escapedatastring(v=vs.110).aspx)? – Mehrzad Chehraz Apr 04 '16 at 11:08
  • @MehrzadChehraz, Yes. Uri.EscapeDataString and EscapeUriString, but both return unusefull data. EscapeUriString, do nothing on my url, and EscapeDataString do encode in my Url. Only need url escaped to put in my xml. Thanks – fipcurren88 Apr 04 '16 at 11:38
  • Could you please try to use [Uri.EscapeComponent | escapeComponent method](https://msdn.microsoft.com/en-us/library/windows/apps/windows.foundation.uri.escapecomponent.aspx)? – Grace Feng Apr 05 '16 at 07:38

0 Answers0