2021년 6월 22일 화요일

C# - Request.ServerVariables (URL, IP주소 등등)


Request Object인 ServerVariables Collection의 전체 값을 확인해보자


ServerVariables의 함수를 사용하여 IP주소, 도메인 주소 등 많은 요소들의 정보를 알아낼 수 있다.


// 클라이언트(사용자) IP 주소 (xxx.xxx.xxx.xxx)

Request.ServerVariables["REMOTE_HOST"];

// 서버 IP 주소 (xxx.xxx.xxx.xxx)

Request.ServerVariables("LOCAL_ADDR");

// 도메인 주소 (ggmouse.tistory.com)

Request.ServerVariables["HTTP_HOST"];

// 현재 경로 (/Test/ikTest.aspx)

Request.ServerVariables["PATH_INFO"];



이외에 전체 요소를 한번에 확인해보자


int loop1, loop2;

System.Collections.Specialized.NameValueCollection coll;

coll = Request.ServerVariables;

String[] arr1 = coll.AllKeys;

for (loop1 = 0; loop1 < arr1.Length; loop1++)

{

    Response.Write("<pre> " + arr1[loop1] + "</pre>");

    String[] arr2 = coll.GetValues(arr1[loop1]);

    for (loop2 = 0; loop2 < arr2.Length; loop2++)

    {

        Response.Write("<pre>" + Server.HtmlEncode(arr2[loop2]) + "</pre>");

    }

    Response.Write("<br>");

}



javascript - SQL 예약어 제거

  <script language="javascript"> //특수문자, 특정문자열(sql예약어) 제거 function checkSearchedWord(obj){ obj.value = obj.value+&quo...