Solved

format a uri in c#

Posted on 2013-10-22
2
382 Views
Last Modified: 2013-11-04
I need to create a uri string that is unescaped.  I am using HttpClient, URI, and trying to use the UriFormat class, but I can't find any examples of this.  Any help appreciated.

btw, this is for a GET request.
0
Comment
Question by:dhenderson12
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 7

Accepted Solution

by:
tipsybroom earned 500 total points
ID: 39592106
I'm not sure why you want to decode it because the browser will do the proper decoding. But anyway, to revert it you can use HttpUtility.HtmlDecode in the System.Web namespace:

var encoded = "http://www.someurl.com/profile.php?mode=register&agreed=true";
var decoded = HttpUtility.HtmlDecode(encoded);

Open in new window


The value of decoded is:

http://www.someurl.com/profile.php?mode=register&agreed=true
0
 

Author Comment

by:dhenderson12
ID: 39592307
thx for response.  a couple of things:
1.  I am using vs2012 and .net 4.5 ... I don't have the system.web.httputility namespace available to me.  at least, I can't find it.
2. I am using the HttpClient to send the request and I don't know how to not url encode the uri string.  I need it to be plain text.
3. on a previous call the service returns a sessionId that is urlencoded.  I need to decode this value because it is part of the uri string:  /theService/{sessionId}/get-next-event.

any thoughts?
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
PrintingFoundIt(Almost!(Damn!)) 1 37
Sort GridView by ID Descending 1 24
Adding where clause to entity statement c# 1 47
locate sql commands in C# visual studio Project 6 37
Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question