블로그 이미지
Magic_kit
study 관련자료를 한곳으로 자기 개발 목적으로 재태크 재무 관리 목적으로 일상생활의 팁을 공유 하기 위하여 블로그를 개설 하였습니다.

calendar

1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28

Category

Recent Post

Recent Comment

Archive

2009. 10. 5. 14:04 .Net Project/ASP.NET 3.5 Sp1
반응형

멤버 HttpRequest : 클라이언트에서 서버측 어떤 결과값을 요청 
                         인프라입니다. HttpRequest 개체를 초기화 합니다.

웹 요청 도중 Asp.net이 클라이언트에서 보낸 Http 값을 읽을 수 있도록 하고,
있으며, HttpRequest 형식에서는 다음과 같은 멤버를 노출하고 있습니다.

QueryString[] : Get방식으로 넘겨져온 쿼리 스트링 값인 Key와 Value를 전달
Form[] : Post방식으로 넘겨져온 값을 Key와 Value를 받고자 할때 사용
Params[] :  사용자로부터 전송된 Get/Post방식 모두 받고자 할 때 사용
UserHostAddress : 현재 접속자의 IP주소 문자열 반환하여 준다
ServerVariables[] : 현재 접속자의 주요 서버 환경 변수 값을 알려준다
cookies[] : 저장된 쿠키의 값을 읽어온다
Url : 현재 웹 페이지의 URL을 반환해준다
PhysicalApplicationPath : 현재 웹 사이트의 가상 디렉토리의 물리적인 경로

<참고>
http://msdn.microsoft.com/ko-kr/library/system.web.httprequest_members.aspx



using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class FrmRequest : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
       string strUserId = "";
       string strPassword = string.Empty;
       string strName = "";
       string strAge = string.Empty;

        //[1] Request 객체의 QueryStyring 컬렉션
       strUserId = Request.QueryString["txtUserID"];

        //[2]Request객체의 Params 컬렉션
       strPassword = Request.Params["txtPassword"];
   
        //[3]Request 객체의 Form 컬렉션
       strName = Request.Form["txtName"];

        //[4]Request 객체 자체로 받기
       strAge = Request["txtAge"];
       string strMsg = string.Format(
            "입력하신 아이디는 {0}이고 <br />"
            + "암호는 {1} 입니다 <br />"
            + "이름은 {2} 이고, <br />"
            + "나이는 {3}살 입니다 <br />",
            strUserId, strPassword, strName, strAge);

       Response.Write(strMsg);

    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        //Empty
        //다른 방식으로 표현
        //string name = txtName.Text;
        //int age = Convert.ToInt16(txtAge.Text);

    }
}





반응형
posted by Magic_kit