Solved

.NET Uri object and encoded forward slashes

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Turn on intranet settings 1 41
how to read json value 2 31
WCF Service Application cannot connect from TCP terminal 1 14
Windows Media Player 2 16
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
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

896 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