Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>It keeps the original string internally, for example, the following code:</p> <pre><code> Uri u = new Uri("http://www.example.com/path?var=value%2fvalue"); Console.WriteLine(u.OriginalString); </code></pre> <p>will display</p> <pre><code>http://www.example.com/path?var=value%2fvalue </code></pre> <p><strong>EDIT</strong>: I have update the code found in the <a href="http://connect.microsoft.com/VisualStudio/feedback/details/94109/system-uri-constructor-evaluates-escaped-slashes-and-removes-double-slashes" rel="noreferrer">Connect Link Workaround</a> for recent .NET versions. Here it is:</p> <pre><code>// System.UriSyntaxFlags is internal, so let's duplicate the flag privately private const int UnEscapeDotsAndSlashes = 0x2000000; private const int SimpleUserSyntax = 0x20000; public static void LeaveDotsAndSlashesEscaped(Uri uri) { if (uri == null) throw new ArgumentNullException("uri"); FieldInfo fieldInfo = uri.GetType().GetField("m_Syntax", BindingFlags.Instance | BindingFlags.NonPublic); if (fieldInfo == null) throw new MissingFieldException("'m_Syntax' field not found"); object uriParser = fieldInfo.GetValue(uri); fieldInfo = typeof(UriParser).GetField("m_Flags", BindingFlags.Instance | BindingFlags.NonPublic); if (fieldInfo == null) throw new MissingFieldException("'m_Flags' field not found"); object uriSyntaxFlags = fieldInfo.GetValue(uriParser); // Clear the flag that we don't want uriSyntaxFlags = (int)uriSyntaxFlags &amp; ~UnEscapeDotsAndSlashes; uriSyntaxFlags = (int)uriSyntaxFlags &amp; ~SimpleUserSyntax; fieldInfo.SetValue(uriParser, uriSyntaxFlags); } </code></pre> <p>Of course, it's a hack, so you should use it at your own risks :-)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload