Server.UrlEncode와 HttpUtility.UrlEncode의 차이점
출처 :http://www.devpia.com/Forum/BoardView.aspx?no=544&forumname=aspnet_lec
결론>
Server.UrlEncode(문자열) 는 HttpUtility.UrlEncode(문자열, Response.ContentEncoding)
과 같습니다.
지식 획득 경로>
asp에서 작성한 쿠키를 asp.net에서 쓰려고 하는데 값이 서로 다르게 나와서 서핑하다가 찾은 것이
데브피아에서 남승우 님의
도움을 받아
ASP.NET이 기본적으로 쿠키를 UrlEncode 형식으로 인코딩하지 않는다.(http://support.microsoft.com/default.aspx?scid=kb;ko;313282)라는 1차 지식을 얻었습니다.
그래서 HttpUtility.UrlDecode() 메소드를 이용 쿠키값을 가져왔으나 유독 한글이 안나오거나 깨져 나와서
구글에서 'httputility.urlencode server.urlencode'라는 단어로 검색해서
http://www.dotnet247.com/247reference/msgs/39/196310.aspx를 참조해서 아래와 같이 테스트 해보았습니다.
test.asp
<%
Response.Write Server.UrlEncode("관리자")
-> %b0%fc%b8%ae%c0%da
%>
test.aspx
<%
Response.Write(Server.UrlEncode("관리자"));
-> %b0%fc%b8%ae%c0%da
Response.Write("<br/>");
Response.Write(HttpUtility.UrlEncode("관리자"));
-> %ea%b4%80%eb%a6%ac%ec%9e%90
Response.Write("<br/>");
Response.Write(HttpUtility.UrlEncode("관리자",
System.Text.Encoding.GetEncoding("euc-kr")));
->%b0%fc%b8%ae%c0%da
%>