How to get Uri.EscapeDataString to comply with RFC 3986

后端 未结 5 1431
死守一世寂寞
死守一世寂寞 2020-11-30 04:07

The Uri class defaults to RFC 2396. For OpenID and OAuth, I need Uri escaping consistent with RFC 3986.

From the System.Uri class documentation:

5条回答
  •  难免孤独
    2020-11-30 04:20

    This has actually been fixed in .NET 4.5 to work by default, see here.

    I just created a new library called PUrify (after running into this issue) which will handle getting this to work for .NET pre 4.5 (works for 3.5) and Mono through a variation of the approach in this post. PUrify doesn't change EscapeDataString but it does let you have Uris with reserved chars which will not be escaped.

提交回复
热议问题