what is virtual path

Posted by Rajeshk under ASP.NET on 11/9/2012 | Points: 10 | Views : 14600 | Status : [Member] | Replies : 5
hi,
Can any bodytell me the what is virtual path and where we use that ....

Thanks&Regards
rajeshkommireddy@gmail.com



Responses

Posted by: Sravya on: 11/9/2012 [Member] Starter | Points: 25

Up
0
Down
Hi..Rajesh

A virtual path is shorthand to represent physical paths. If you use virtual paths, you can move your pages to a different domain (or server) without having to update the paths.
For More Information...you refer these follow link

http://www.w3schools.com/aspnet/webpages_folders.asp?output=print

Thanks & Regards
Sravya

Rajeshk, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Saratvaddilli on: 11/9/2012 [Member] [MVP] Bronze | Points: 25

Up
0
Down
When working with resources in a Web project, you must often specify a path for the resource. For example, you might use a URL path to reference an image file in a page or the URL of a page elsewhere in the Web site. Similarly, code in your Web project might use a physical file path to a server-based file to read or write the file. ASP.NET provides ways for you to refer to resources and to determine the paths of pages or other resources in the application.
using this we can get path
Request.Url.GetLeftPart(UriPartial.Authority) + Request.ApplicationPath

VirtualPathUtility.GetDirectory(Request.Path)


Thanks and Regards
V.SaratChand
Show difficulties that how difficult you are

Rajeshk, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Muhsinathk on: 11/22/2012 [Member] Bronze | Points: 25

Up
0
Down
Virtual path

1)The virtual path provider system is a method of raising the layer of abstraction when it comes to ASP.NET and the file system.
2)This virtual path provider system is primarily driven by three abstract classes in the System.Web.Hosting namespace, VirtualPathProvider, VirtualFile, and VirtualDirectory.
3)Virtual file system can contain any file in the web application other than
1) Binaries
2) Web.config
3) Global.asax
4)Files in special folder such as App_Data and so on
4)ASP.NET the "~" tilde indicates the root of a virtual path. We need the tilde because otherwise ASP.NET can't figure out if a path is absolute or relative.

Virtual paths

~/App_Data/Sample.xml
~/
~/Map.txt

Physical paths

C:\Website\Files\Sample.xml
C:\Website\Default.aspx
C:\Website\Map.txt
5)The domain name part of the path is not really a property of the application itself, but depends on the requesting URL. You might be able to reach a single Web site from many different host names. To get the domain name associated with the current request, along with the virtual path of the current application, you could do:

Request.Url.GetLeftPart(UriPartial.Authority) + Request.ApplicationPath


Rajeshk, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Muhsinathk on: 11/22/2012 [Member] Bronze | Points: 25

Up
0
Down
Please mark as answer if it helpful to you..That helps others who search the same..

Rajeshk, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Siba_Sahoo on: 12/4/2012 [Member] Starter | Points: 25

Up
0
Down
Virtual path is only site name like "www.google.com"
but physical path for that is different which accessed by virtual name "www.google.com"

Rajeshk, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response