블로그 이미지
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. 15:54 .Net Project/ASP.NET 3.5 Sp1
반응형

Application : 응용 프로그램 전체 레벨에서 변수 등을 선언

Lock() : 애플리케이션 변수를 잠그는 메서드
Unlock() : 잠긴 애플리케이션 변수를 해제하는 메서드
Add() :  애플리케이션 변수 만들때 사용
Application_start() : 웹 애플리케이션이 시작 할 때 발생
                            (웹 사이트에 첫 번재 사용자가 방문할 때 발생)
Application_End() : 웹 응용프로그램이 끝날때 발생
                            (웹 사이트에서 마지막 사용자가 나간 후 발생)
<참고>
http://msdn.microsoft.com/ko-kr/library/system.windows.application_members(VS.85).aspx 


Session 개체 : 각각의 사용자별 변수를 선언하는 등의 기능
                          웹 사이트에 사용자가 접속 할때 마다 동일한 이름으로
                          사용자별로 전역 변수를 생성

HttpSessionState 클래스의 속성 및 메서드에 프로그래밍 방식으로 액세스
할 수 있도록 하고 있으며, Asp.Net 페이지는 System.web 네임스페이스에 대한
기본 참조를 포함하므로 HttpContext클래스 포함

SessionID : 현재 세션의 고유번호 값 반환
SessionTimeOut : 세션 시간 기록 : 기분값20분. 더 추가시키거나 줄일 경우 사용
Abandon()  : 현재 세션 지우기
Session_Start() : 한명의 사용자(세션)가 방문시 실행
Session_End() : 한명의 사용자가 나간 후 실행

<참고>
http://msdn.microsoft.com/ko-kr/library/system.web.httpcontext.session(VS.80).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 FrmApplicationSession : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //[1] Application 변수 1증가
        //session 전역변수 : Private한 전역변수

        if (Application["Count"] == null)
        {
           Application.Lock(); //먼저 온 사용자가 변수 수정 잠그기 
           Application["Count"] = 1; //응용프로그램 변수선언/내용 수정(초기화)
           Application.UnLock(); //잠금해제 : 다른 사용자가 사용가능
       
        }
        else
        {
            Application["Count"] = (int)Application["Count"] + 1;
        }
        //[2] Session 변수 1 증가        
        if (Session["Count"] ==null)
        {
            Session["Count"] = 1; //세션변수 선언과 동시에 1로 초기화

        }
        else
        {
            Session["Count"] = (int)Session["Count"] + 1;
        }
        //출력
        //누구나 다 1씩 증가
        this.lblApplication.Text = Application["Count"].ToString();

        //현재 접속자만 1씩 증가
        this.lblSession.Text = Session["Count"].ToString();
       
        //현재 접속자의 고유 접속번호
        this.lblSessionID.Text = Session.SessionID;

        //현재 세션의 유지 시간
        this.lblTimeout.Text = Session.Timeout.ToString();
    }
}






반응형
posted by Magic_kit
2009. 10. 5. 14:51 .Net Project/ASP.NET 3.5 Sp1
반응형

Server : 서버측 정보를 확인 httpServerutility 클래스 인스턴스

MapPath(",") : 현재 파일과 같은 경로 값 반환
Execute()  : 다른 파일 포함 후 제어권 돌아옴
Transfer() : 다른 파일 포함 후 제어권 넘김
UrlPathEncode() 넘겨져 온 쿼리 스트링을 유니코드로 변환
ScriptTimeOut : 서버측에서 현재 Aspx페이지를 몇 초간 처리할 건지 설정

<참고>
http://support.microsoft.com/kb/290292/ko

http://msdn.microsoft.com/ko-kr/library/system.web.httprequest.mappath(VS.80).aspx





using System;

public partial class FrmserverMapPath : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
       
//현재 웹 폼의 서버측의 물리적경호
        this.Label1.Text = Server.MapPath(".");

        //현재 스크립트 파일의 루트 경호
        this.Label2.Text = Request.ServerVariables["SCRIPT_NAME"];
    }
}




--Excute



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 FrmServerExecute : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //현재 웹폼에 또 다른 웹품을 추가 : 제어권 돌아옴
        Server.Execute("./FrmRequest.aspx");

        Server.Execute("./RrmRequestUserHostAddress.aspx");

        //현재 웹폼에 또 다른 웹폼을 추가 : 제어권넘김
        Server.Transfer("./FrmHi.aspx");

        //Transfer() = Execute() + Response.End()
        //아래 구문은 실행 안됨..

        Response.Write("Test");
    }
}

<참고>
http://support.microsoft.com/kb/224363/ko





반응형
posted by Magic_kit
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
2009. 10. 5. 14:03 .Net Project/ASP.NET 3.5 Sp1
반응형



<%@ Page Language="C#" AutoEventWireup="true" CodeFile="FrmResponseRedirect.aspx.cs" Inherits="FrmResponseRedirect" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>페이지 이동</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <input type ="button" value="이동" onclick= 
                      "location.href = 'http://www.naver.com';" />
        <asp:Button ID="btnNaver" runat="server" Text="네이버로 이동"
            onclick="btnNaver_Click" />     
    
    </div>
    </form>
</body>
</html>
----------------------------------------------------------------------
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 FrmResponseRedirect : System.Web.UI.Page
{
   
protected void btnNaver_Click(object sender, EventArgs e)
    {
        //이동
        Response.Redirect("
http://www.naver.com /");
    }
}





반응형
posted by Magic_kit