ASP.NET HttpRequest

차차·2021년 12월 6일
0

ASP.NET

목록 보기
2/3

HttpRequest 클래스는 ASP.NET이 클라이언트에서 보낸 HTTP 값을 읽을 수 있도록 합니다

  • Requset.UserHostAddress : 클라이언트의 IP주소얻기
protected void Page_Load(object sender, EventArgs e)
{
    // 웹 폼에서 현재 접속자의 IP 주소 얻기
    Label1.Text = Request.UserHostAddress; // 추천
    Label2.Text = Request.ServerVariables["REMOTE_HOST"];
    Label3.Text = Request.ServerVariables["REMOTE_ADDR"];
}
  • Request.Cookies : 클라이언트에서 보낸 쿠키 컬렉션을 가져온다
string cookie = Request.Cookies["쿠키이름"]
  • Request.Form : 폼 변수의 컬렉션을 가져온다
  • Request.QueryString : 클라이언트에서 보낸 쿼리 문자열 변수
string fullname1 = Request.QueryString["fullname"]; // 쿼리 문자열만 찾음
string fullname2 = Request["fullname"]; // 모든 HTTP 요청 컬렉션에서 "fullname" 키를 찾음 
profile
개발하는 돌멩이🙄🙄👻

0개의 댓글