-5

I have a Sandbox solution webpart1 that receives a absolute URL in the webpart settings's section.

Due to native limitations of sandboxes solutions, I'm looking for a C# - code for encode an absolute URL without using HttpServerUtility and related/pre-built classes.

I already search and try the following code and also this comment, but I can't understand or get a more legible code or approach for create a more sutile for my specific situation.


1 I'm working on a sandboxed solution that I was developed a few months ago and change sandboxed solution to Apps/Add-ins is not valid in this case.

Community
  • 1
  • 1
Mauricio Arias Olave
  • 2,259
  • 4
  • 25
  • 70

2 Answers2

0

Thanks to @MethodMan's comment which lined to similar question, it wasn't need build C# custom code for this purpose.

You can use the static method Uri.UnescapeDataString() to decode your URL's.

Here is the full answer:

String urlAbsoluteSample = "http://..."; // use any absolute URL for your purpose.
Label1.Text = "Encoded absolute URL: " + Uri.EscapeDataString(urlsFeeds[0]);
Community
  • 1
  • 1
Mauricio Arias Olave
  • 2,259
  • 4
  • 25
  • 70
0
var urlAbsoluteSample = "http://stackoverflow.com/questions/34075880/encode-string-url-without-using-httpserverutility?noredirect=1#comment55905829_34075880";
var labelText = "Encoded absolute URL: " + Uri.EscapeDataString(urlAbsoluteSample);

Encoded absolute URL: http%3A%2F%2Fstackoverflow.com%2Fquestions%2F34075880%2Fencode-string-url-without-using-httpserverutility%3Fnoredirect%3D1%23comment55905829_34075880

MethodMan
  • 18,625
  • 6
  • 34
  • 52