윈폼이나 모듈단위에서 특정 웹페이지를 파라메타와 함께 호출하는 방밥을 알아 본다.

1. 아주 심필한 방법
 -  System.Diagnostics.Process.Start("http://www.test.com/test.aspx?param1=1&param2=2");
    이것의 단점은 해당 프로세서가 실제로 실행되어 버린다는 것이다.
    즉, 브라우저가 열려버린다는 것이다.

2. 브라우저를 열지 않고 웹페이지 호출하기 
    string url = "http://www.test.com/test.aspx";
    WebRequest request = WebRequest.Create(url);
    request.Method = "POST";
    request.ContentType = "application/x-www-form-urlencoded";
       
    //전달할 파라메타    
    string sendData = "param1=1&param2=2"; 
                      
    byte [] buffer;
    buffer = Encoding.Default.GetBytes(sendData);
    request.ContentLength = buffer.Length;
    Stream sendStream = request.GetRequestStream();
    sendStream.Write( buffer, 0, buffer.Length);
    sendStream.Close(); 

    이렇게 하면 윈폼or 모듈단위에서 브라우저 실행없이 웹페이지 호출이 가능해진다.

출처 : http://www.mkexdev.net

2번을 실행 시키긴 위해선
using System.Net;
using System.IO;
필요


'IT' 카테고리의 다른 글

현재 컴퓨터에 설치된 디바이스 장치 정보 알아오기  (0) 2009.02.09
문자열 가지고 놀기~  (0) 2009.02.09
인증 성공!!  (1) 2008.09.16
인증 패킷  (0) 2008.09.09
패킷 분석중.  (0) 2008.09.06

+ Recent posts