Type of issue
Missing information
Description
I needed to escape some values to insert in a URI query string. I found the following methods (maybe there are more?):
HttpUtility.UrlEncode() (no warning note but I think there should be one (see below), link)
HttpUtility.UrlPathEncode() (DO NOT USE (but not deprecated), link)
WebUtility.UrlEncode() (note about non-standard behavior, link)
Uri.EscapeDataString() (the only standard-compliant one?, link)
Uri.EscapeUriString() (OBSOLETE, link)
Uri.EscapeString() (OBSOLETE, link)
The most standard-conforming methods seems to be Uri.EscapeDataString(). At first, I used HttpUtility.UrlEncode() but the API I was talking to was not happy at all with the + used to replace the spaces since it interpreted the + literally.
I think a warning similar to the one found on https://learn.microsoft.com/en-us/dotnet/api/system.net.webutility.urlencode?view=net-10.0#system-net-webutility-urlencode(system-string) should be added on the following methods:
HttpUtility.UrlEncode()
HttpUtility.UrlPathEncode()
Also, I think that this kind of warning should be moved to the Definition section to be immediately visible, since it could easily be missed otherwise. I would also not be unhappy to see this note promoted to a red Caution banner with a stronger recommendation against I don't know if that conforms to the usual practices in Microsoft documentation though.
Page URL
https://learn.microsoft.com/en-us/dotnet/api/system.web.httputility.urlencode?view=net-10.0
Content source URL
https://github.com/dotnet/dotnet-api-docs-temp/blob/live/xml/System.Web/HttpUtility.xml
Document Version Independent Id
2c52784d-6560-1db6-26b2-26af04e04ce8
Platform Id
ac6466f5-64ce-6f49-7050-11b172476182
Article author
@dotnet-bot
Type of issue
Missing information
Description
I needed to escape some values to insert in a URI query string. I found the following methods (maybe there are more?):
HttpUtility.UrlEncode()(no warning note but I think there should be one (see below), link)HttpUtility.UrlPathEncode()(DO NOT USE (but not deprecated), link)WebUtility.UrlEncode()(note about non-standard behavior, link)Uri.EscapeDataString()(the only standard-compliant one?, link)Uri.EscapeUriString()(OBSOLETE, link)Uri.EscapeString()(OBSOLETE, link)The most standard-conforming methods seems to be
Uri.EscapeDataString(). At first, I usedHttpUtility.UrlEncode()but the API I was talking to was not happy at all with the+used to replace the spaces since it interpreted the+literally.I think a warning similar to the one found on https://learn.microsoft.com/en-us/dotnet/api/system.net.webutility.urlencode?view=net-10.0#system-net-webutility-urlencode(system-string) should be added on the following methods:
HttpUtility.UrlEncode()HttpUtility.UrlPathEncode()Also, I think that this kind of warning should be moved to the Definition section to be immediately visible, since it could easily be missed otherwise. I would also not be unhappy to see this note promoted to a red Caution banner with a stronger recommendation against I don't know if that conforms to the usual practices in Microsoft documentation though.
Page URL
https://learn.microsoft.com/en-us/dotnet/api/system.web.httputility.urlencode?view=net-10.0
Content source URL
https://github.com/dotnet/dotnet-api-docs-temp/blob/live/xml/System.Web/HttpUtility.xml
Document Version Independent Id
2c52784d-6560-1db6-26b2-26af04e04ce8
Platform Id
ac6466f5-64ce-6f49-7050-11b172476182
Article author
@dotnet-bot