• 쇼핑몰
  • 커뮤니티
  • 북마크

vb.net




[WinHttp] [vb.net] UrlEncode

하나를하더라도최선을
2020.04.01 12:08 593 0

본문



Couldn't find any good examples comparing them so:

string testString = "http://test# space 123/text?var=val&another=two";

Console.WriteLine("UrlEncode: " + System.Web.HttpUtility.UrlEncode(testString));

Console.WriteLine("EscapeUriString: " + Uri.EscapeUriString(testString));

Console.WriteLine("EscapeDataString: " + Uri.EscapeDataString(testString));

Console.WriteLine("EscapeDataReplace: " + Uri.EscapeDataString(testString).Replace("%20", "+"));

Console.WriteLine("HtmlEncode: " + System.Web.HttpUtility.HtmlEncode(testString));

Console.WriteLine("UrlPathEncode: " + System.Web.HttpUtility.UrlPathEncode(testString));


//.Net 4.0+

Console.WriteLine("WebUtility.HtmlEncode: " + WebUtility.HtmlEncode(testString));


//.Net 4.5+

Console.WriteLine("WebUtility.UrlEncode: " + WebUtility.UrlEncode(testString));


Outputs:

UrlEncode: http%3a%2f%2ftest%23+space+123%2ftext%3fvar%3dval%26another%3dtwo

EscapeUriString: http://test#%20space%20123/text?var=val&another=two

EscapeDataString: http%3A%2F%2Ftest%23%20space%20123%2Ftext%3Fvar%3Dval%26another%3Dtwo

EscapeDataReplace: http%3A%2F%2Ftest%23+space+123%2Ftext%3Fvar%3Dval%26another%3Dtwo

HtmlEncode: http://test# space 123/text?var=val&another=two

UrlPathEncode: http://test#%20space%20123/text?var=val&another=two


//.Net 4.0+

WebUtility.HtmlEncode: http://test# space 123/text?var=val&another=two


//.Net 4.5+

WebUtility.UrlEncode: http%3A%2F%2Ftest%23+space+123%2Ftext%3Fvar%3Dval%26another%3Dtwo





댓글목록 0

등록된 댓글이 없습니다.