Solved

.NET Uri object and encoded forward slashes

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

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…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display

739 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