The best ASP.NET Web Pages folder Tutorial In 2024, In this tutorial you can learn Logical folder structure,Physical folder structure,Virtual name and the physical name,URL and path,~ Operator,Server.MapPath method,Href method,
This chapter provides information folders and folder path to knowledge.
In this chapter, you will learn:
The following are typical ASP.NET Web site folder structure:
In the site "Images" folder on the computer's physical folder structure might look like:
C: \ Documents \ MyWebSites \ Demo \ Images
In the example above, for example:
The name of the virtual image of the site may be "Images / pic31.jpg".
Corresponding physical name is "C: \ Documents \ MyWebSites \ Demo \ Images \ pic31.jpg".
URL is used to access the Web site files: /html/html-tutorial
URL corresponding to a physical file on the server: C: \ MyWebSites \ w3cschool \ html \ html-tutorial
Virtual path is the physical path of a shorthand representation. If you use a virtual path, when you change your domain or pages moved to other servers, you can not update path.
URL | /html/html-tutorial |
Server Name | w3cschool |
Virtual path | /html/html-tutorial |
Physical path | C: \ MyWebSites \ w3cschool \ html \ html-tutorial |
The root directory of the disk drive are written in C:, but the site's root directory is / (slash).
Virtual path to the Web folder is often not identical with the physical folder.
In your code, your code will need to decide to use physical paths and virtual paths.
ASP.NET folder path There are three tools: the ~ operator, Server.MapPath method and the Href method.
Use ~ operator, the virtual path specified in the programming code.
If you use the ~ operator migrate your site to a different location or a different folder, you can not change any of your code is:
Server.MapPath method virtual path (/index) is converted into a physical path to the server understands (C: \ Documents \ MyWebSites \ Demo \ default).
When you need to open the data file on the server, you can use this method (only to provide a complete physical path to access data files):
In the next chapter of this tutorial, you'll learn more about reading (and writing) data file on the server knowledge.
Href method to convert the code path used to be understood that the path browser (browsers do not understand the ~ operator).
You can create a resource (such as image files and CSS files) path using the Href method.
Usually <a> in HTML, <img> and <link> element to use this method:
Href method is a method WebPage object.