Search code examples
c#-4.0escapinguriinvalid-characters

how to create a Uri with "."


I have a string with "." like https://mysite.com/Relation=My.Test.AL.?Path=MySymbolPath when I create uri from it the "." is truncated. https://mysite.com/Relation=My.Test.AL?Path=MySymbolPath

    var uristring = "https://mysite.com/Relation=My.Test.AL.?Path=MySymbolPath";
    var uri = new Uri(Uri.EscapeUriString(uristring ));

See uristring has "AL.", but uri.AbsoluteUri does not, it has "AL" Do you know how to prevent it?

Thanks


Solution

  • There is a known bug in .NET framework. Workaround exists. Thanks see HttpWebRequest to URL with dot at the end

    How to create a Uri instance parsed with GenericUriParserOptions.DontCompressPath

    http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/5206beca-071f-485d-a2bd-657d635239c9

    https://connect.microsoft.com/VisualStudio/feedback/details/386695/system-uri-incorrectly-strips-trailing-dots