ASP.NET

11.C# ASP.NET - Server.MapPath

Godffs 2009. 10. 5. 15:35
반응형
MapPath() : 현재 웹 폼의 서버측의 물리적 경로
ServerVariables : 현재 스크립트 파일의 루트(웹 서버상 주소) 경로

FrmServerMapPath.aspx

<div>

    현재 파일( ) 물리적인 전체 경로 :

    <asp:Label ID="Label1" runat="server"></asp:Label><br />

   

    현재 스크립트 파일의 루트(웹서버상주소) 경로 :

    <asp:Label ID = "Label2" runat="server"></asp:Label><br />

</div>


FrmServerMapPath.aspx.cs

protected void Page_Load(object sender, EventArgs e)

{

    //현재 폼의 서버측의 물리적 경로

    this.Label1.Text = Server.MapPath("."); //같은 경로

    //현재 스크립트 파일의 루트 경로

    this.Label2.Text =

    Request.ServerVariables["SCRIPT_NAME"];

}


결과화면

[그림11-1]



반응형