Retrieves the physical path that a virtual path, either absolute or relative, or an application-relative path maps to..
Server.MapPath: -
Each file on a Web server has two ways of being accessed - through a virtual path and through a
physical path. The virtual path is the path one would enter into their browser's Address bar, for example:
The bold part of the URL above is referred to as the virtual path. The
physical path is the actual drive, directory, and filename of a particular file on
the Web server. For example, on your computer, if you run Windows 9X, your
Win.ini
file's physical path is
C:\WINDOWS\WIN.INI
(assuming you
installed Windows on your
C:
drive).
If you got a possible solution to your problem, then please mark the post as answer. Help the community to get better.
tim yap
Member
248 Points
109 Posts
Difference of Server.MapPath and Page.MapPath
Sep 12, 2008 02:21 AM|LINK
Hi all,
I just want to know what is the difference between server.mappath and page.mappath?
I try to use this two by passing parameter like this
Server.MapPath("C:\MyFolder"), Server.MapPath("~/MyFolder"),
Page.MapPath("C:\MyFolder"), Page.MapPath("~/MyFolder")
but both didn't work for me,.
thanks for any help
HeartattacK
All-Star
55262 Points
5917 Posts
Moderator
MVP
Re: Difference of Server.MapPath and Page.MapPath
Sep 12, 2008 03:06 AM|LINK
They both map a virtual path to a physical one.
So, if you have a folder named folder1 in your wesite root and that root is in C:\inetpub\www\site1, then:
string path = Server.MapPath("~/folder1");
will set path to C:\inetpub\www\site1\folder1
blog: www.heartysoft.com
twitter: @ashic
tim yap
Member
248 Points
109 Posts
Re: Difference of Server.MapPath and Page.MapPath
Sep 12, 2008 03:53 AM|LINK
HeartattacK
All-Star
55262 Points
5917 Posts
Moderator
MVP
Re: Difference of Server.MapPath and Page.MapPath
Sep 12, 2008 04:04 AM|LINK
Server.MapPath is used to read the physical path of a virtual folder. There's nothing you can "set".
blog: www.heartysoft.com
twitter: @ashic
Nikhil Tripa...
Contributor
2248 Points
435 Posts
Re: Difference of Server.MapPath and Page.MapPath
Sep 12, 2008 04:18 AM|LINK
Hi,
They both map a virtual path to a physical one..
Page.MapPath: -
Retrieves the physical path that a virtual path, either absolute or relative, or an application-relative path maps to..
Server.MapPath: -
Each file on a Web server has two ways of being accessed - through a virtual path and through a physical path. The virtual path is the path one would enter into their browser's Address bar, for example:
The bold part of the URL above is referred to as the virtual path. The physical path is the actual drive, directory, and filename of a particular file on the Web server. For example, on your computer, if you run Windows 9X, your
file's physical path is (assuming you installed Windows on your drive).Nikhil Tripathi,
Web Developer,
Ahmedabad, India.