Solved

.NET Uri object and encoded forward slashes

Posted on 2010-08-15
1
990 Views
Last Modified: 2012-06-21
When I try to encode forward slashes into a Uri object, it always treats them like regular slashes, and thus changes the request path and resulting in 404 error from server.

I tried:

freeText = "aaa/aaa";

Uri requestUrl = new Uri(string.Format(RestCommand,  Uri.EscapeDataString(freeText)), true);

OriginalString: "https://someurl.com/somepath/aaa%2Faaa"
AbsoluteUri: "https://someurl.com/somepath/aaa/aaa"

The AbsoluteUri is the one that gets executed while I need the OriginalString to be the request's final URL. I saw that the dontEscape flag that I'm using in the ctor is deprecated, is there any alternative to it?

Thanks for your time, everybody
0
Comment
Question by:OffiSync
1 Comment
 
LVL 19

Accepted Solution

by:
Rimvis earned 500 total points
ID: 33444309
Check this:System.Uri constructor evaluates escaped slashes and removes double slasheshttp://connect.microsoft.com/VisualStudio/feedback/details/94109/system-uri-constructor-evaluates-escaped-slashes-and-removes-double-slashes#Looks like it is by design. You can try workaroud posted there.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

758 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