Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

format a uri in c#

Posted on 2013-10-22
2
Medium Priority
?
393 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 1500 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

721 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