본문 바로가기
실버라이트
2013.04.30 15:36

실버라이트에서 로컬 IP 가져오는 방법

다물칸 주소복사
조회 수 2296 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
Extra Form
구분 팁&트릭

방법 1.  Web Service를 이용하는 방법 (서버 사이드에서 구현하는 방법)

          WcfService 에서 System.Web.HttpContext.Current.Request.UserHostAddress; 를 이용하여 받아 온다. 


          또 다른 방법으로는 아래 글을 참조 하자.
          /* NOTE: This is another way to do it but the one method is more straight forward: 
   if( HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"] != null) 
        CustomerIP = HttpContext.Current.Request.ServerVariable["HTTP_X_FORWARDED_FOR"].ToString(); 
   else if (HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"] != null)                
CustomerIP = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"].ToString(); 
 */  
          1. HTTP_X_FORWARDED_FRO - This is used to obtain the originating IP address of a client that connected through a proxy.
          2. REMOTE_ADDR - Used to obtain the client IP address if a proxy was not used.





방법 2. Server Side Script 이용하는 방법 (클라이언트 사이드에서 구현하는 방법

            ASP 닷넷 이용.

          

Page_Load 이벤트에 다음 코드 작성
                        InitParam = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];

            ASP 파일에 다음 코드 작성
                        <param name="initParams" value="IPAddress=<%=InitParam%>"/> 세팅 asp

            Application_Startup 이벤트에 다음 코드 작성
                        string ipAddress = e.InitParams["IpAddress"];