In a recent project I had to develop a plugin which is executed in the plugin sandbox. The sandbox restricts the rights plugins to a ‘safe’ amount. See http://msdn.microsoft.com/en-us/library/gg334752.aspx for a description. According to the SDK, web request are allowed.
Part of my task was to send a request to a web service which expects data URL-encoded. Normally you would use following class (part of
HttpUtility.UrlEncode("some data here");
I was surprised that this leads to a
SecurityException if used in a sand-boxed plugin. The sandbox does not allow the use of this class.
Instead of rewriting the method (I hate reinventing the wheel…) I’ve searched for a replacement, and found
Uri.EscapeDataString("some data here");
which is usable in sand-boxed plugins. For my task the result was the same as with
UrlEncode, however I am not sure I they are different in their results.