Solved

format a uri in c#

Posted on 2013-10-22
2
383 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

752 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