Solved

.NET Uri object and encoded forward slashes

Posted on 2010-08-15
1
994 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

772 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