1 June 2012

Path Details in Asp.net - Absolute Path and Relative Path in asp.net


Path Details in Asp.net - Absolute Path and Relative Path in asp.net

        string applicationPath = string.Empty;
        string executionFilePath=string.Empty;
        string filePath = string.Empty;
        string path = string.Empty;

        string physicalApplicationPath = string.Empty;
        string physicalPath = string.Empty;
        string rawUrl = string.Empty;

        String rootPath = string.Empty;
        string mapPath = string.Empty;


        //Relative path
        //Only a Portion of full path

        //Absolute path
        //Contains Root directory and all Sub directory


       // Gets the ASP.NET application's virtual application root path on the server.

         applicationPath = Request.ApplicationPath + "/images/Nature.gif";

        //Output : /ApplicationPathInWeb/images/Nature.gif

        //Gets the virtual path of the current request.

         executionFilePath = Request.CurrentExecutionFilePath;

        //Output : /ApplicationPathInWeb/Default.aspx

         //Gets the virtual path of the current request.for the URL http://www.contoso.com/virdir/page.html/tail,      //the FilePath value is /virdir/page.html.

         filePath = Request.FilePath;

        //Output : /ApplicationPathInWeb/Default.aspx

         //Gets the virtual path of the current request.

         path = Request.Path;

        //Output : /ApplicationPathInWeb/Default.aspx

         physicalApplicationPath = Request.PhysicalApplicationPath;
        //Output:D:\Arun\SupportTools\ApplicationPathInWeb\

         physicalPath = Request.PhysicalPath;
        //Output:D:\Arun\SupportTools\ApplicationPathInWeb\Default.aspx

         rawUrl = Request.RawUrl;
        //Output:/ApplicationPathInWeb/Default.aspx

         rootPath = Server.MapPath("~");
        //Output:D:\Arun\SupportTools\ApplicationPathInWeb

         mapPath = Request.MapPath("~\\nature.jpg");
        //Output:D:\Arun\SupportTools\ApplicationPathInWeb\nature.jpg

No comments:

Post a Comment

Comments Welcome

Consistency level in Azure cosmos db

 Consistency level in Azure cosmos db Azure Cosmos DB offers five well-defined consistency levels to provide developers with the flexibility...