asp.net - How to get physical application path

Get physical application path
.Net framework HttpRequest class enables asp.net to read the HTTP values sent by a client during a Web request.

HttpRequest.PhysicalApplicationPath property allow us to get the physical file system path of the currently executing server application's root directory.

HttpRequest class PhysicalApplicationPath property exists in System.Web namespace. this property return value data type is System.String. returned string value represents the file system path of the current application's root directory.

the following asp.net c# example code demonstrate us how can we get the web site's physical application path programmatically at run time in asp.net.
PhysicalApplicationPath.aspx

<%@ Page Language="C#" %>

<!DOCTYPE html>

<script runat="server">
    protected void Button1_Click(object sender, System.EventArgs e) {
        string phyAppPath = Request.PhysicalApplicationPath;
        Label1.Text = "Physical Application Path: " + phyAppPath;
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>How to get the physical application path programmatically in asp.net</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h2 style="color:Teal">asp.net example: get physical application path</h2>
        <asp:Label 
            ID="Label1" 
            runat="server" 
            Font-Size="Large" 
            ForeColor="DarkRed"
            >
        </asp:Label>
        <br /><br />
        <asp:Button 
            ID="Button1" 
            runat="server" 
            Font-Bold="true" 
            ForeColor="DodgerBlue"
            Text="Get Physical Application Path"
            OnClick="Button1_Click"
            />
    </div>
    </form>
</body>
</html>
More asp.net examples