Solved

format a uri in c#

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

Independent Software Vendors: 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

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…
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

623 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