Frustratingly .net Core early releases were without URL Encode and Decode methods. Whereas previously you were able to access the HTTPUtility namespace for encoding and decoding strings, this was not ported to .net core.
Microsoft has moved the UrlEncode and Decode methods into a WebUtility static class. If you are super nosy you can see the code that’s doing your encoding here.
To get access you need to install this nuget package, which at the time of writing means running this command from your package command line :
Install-Package Microsoft.AspNet.WebUtilities -Pre
Now you have access to URL Encoding
var myEncodedString = System.Net.WebUtility.UrlEncode("my string");
1 thought on “Using URL Encode with .net Core”
It’s been over a year since this article published, so I assume the way to accomplish this in .Net is completely different now.