I want its output as uppercase. This is what I get on Server.UrlEncode("http://")
:
http%3a%2f%2f
but I need:
http%3A%2F%2F
Is there built-in solution in C#?
The url encoded shall serve as signature base string (input to signature algorithm) to create digest (hash). The hash will then be verified by other system (java,php,etc), so they need to recreate the hash by signature reconstruction first.
This will uppercase all escaped characters in your string.
string url = "http://whatever.com/something";
string lower = Server.UrlEncode(url);
Regex reg = new Regex(@"%[a-f0-9]{2}");
string upper = reg.Replace(lower, m => m.Value.ToUpperInvariant());
Uri.EscapeDataString("http://")
This code return
http%3A%2F%2F
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With