public MapPath ( string virtualPath ) : string | ||
virtualPath | string | |
return | string |
string virtualPath = "~/Views/Home/Index.cshtml"; string physicalPath = Request.MapPath(virtualPath);
string virtualPath = "~/assets/css/styles.css"; string physicalPath = Request.MapPath(virtualPath);In this example, we are getting the physical path of a CSS file named "styles" which is located in the assets/css folder. The method returns the physical path of the file as a string. Package library: System.Web Note: In .NET Core, this method is available under Microsoft.AspNetCore.Http namespace.