Solved

format a uri in c#

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

759 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now