반응형
    
    
    
  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>");
}반응형
    
    
    
  '프로그래밍 > C# ' 카테고리의 다른 글
| [C#] 파일 다운로드 한글 깨짐 방지 (0) | 2017.03.02 | 
|---|---|
| [C#] URL에서 원하는 부분만 잘라서 보자 (파라미터 제거) (0) | 2017.02.01 | 
| [C#] StringBuilder과 InnerHtml으로 서버단에서 HTML 작성 (0) | 2017.02.01 | 
| [C#] 페이지간 변수 주고받기 (파라미터값 전달) GET방식, POST방식 (1) | 2017.02.01 | 
| [C#] 연산자 (0) | 2017.02.01 |