473,406 Members | 2,345 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Difference between Server.mappath and Page.resolveURL

Hi,

Can any one let me know what is difference between Server.mappath and
Page.resolveURL and what are the situations we use them.

Thanks,
Sandy

Dec 14 '06 #1
4 14131
The ResolveUrl method is designed to create a friendly URL for a given
resource. For example, when you have a control that references an image,
you'll want the image to be referenced correctly when that control is placed
within a page. The ResolveUrl will create the url in a friendly way that is
relative to the page instead of relative to the control.

The Server.MapPath is used to find the file system path for a given
resource. For example: Server.MapPath("web.config") may give something like
c:\inetpub\wwwroot\web.config. It's used when you're trying to work with
files from the server's file system, such as saving uploaded files, creating
files on the server, referencing file-based databases.
--

Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006
"SandyIsCool" <sa*************@gmail.comwrote in message
news:11**********************@79g2000cws.googlegro ups.com...
Hi,

Can any one let me know what is difference between Server.mappath and
Page.resolveURL and what are the situations we use them.

Thanks,
Sandy

Dec 14 '06 #2
Thanks a lot Mark. That really helped this novice.
Thanks again.
Sandy

Mark Fitzpatrick wrote:
The ResolveUrl method is designed to create a friendly URL for a given
resource. For example, when you have a control that references an image,
you'll want the image to be referenced correctly when that control is placed
within a page. The ResolveUrl will create the url in a friendly way that is
relative to the page instead of relative to the control.

The Server.MapPath is used to find the file system path for a given
resource. For example: Server.MapPath("web.config") may give something like
c:\inetpub\wwwroot\web.config. It's used when you're trying to work with
files from the server's file system, such as saving uploaded files, creating
files on the server, referencing file-based databases.
--

Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006
"SandyIsCool" <sa*************@gmail.comwrote in message
news:11**********************@79g2000cws.googlegro ups.com...
Hi,

Can any one let me know what is difference between Server.mappath and
Page.resolveURL and what are the situations we use them.

Thanks,
Sandy
Dec 14 '06 #3
Hi
Mark.

I used the below code for an image button

image1.imageurl="~/images/image1.jpg";
image1.imageurl=Page.ResolveUrl("~/images/image1.jpg");

Both statements work fine..
I want to see a case where resolveURL method makes a difference.
Thanks,
Sandeep

SandyIsCool wrote:
Thanks a lot Mark. That really helped this novice.
Thanks again.
Sandy

Mark Fitzpatrick wrote:
The ResolveUrl method is designed to create a friendly URL for a given
resource. For example, when you have a control that references an image,
you'll want the image to be referenced correctly when that control is placed
within a page. The ResolveUrl will create the url in a friendly way that is
relative to the page instead of relative to the control.

The Server.MapPath is used to find the file system path for a given
resource. For example: Server.MapPath("web.config") may give something like
c:\inetpub\wwwroot\web.config. It's used when you're trying to work with
files from the server's file system, such as saving uploaded files, creating
files on the server, referencing file-based databases.
--

Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006
"SandyIsCool" <sa*************@gmail.comwrote in message
news:11**********************@79g2000cws.googlegro ups.com...
Hi,
>
Can any one let me know what is difference between Server.mappath and
Page.resolveURL and what are the situations we use them.
>
Thanks,
Sandy
>
Dec 15 '06 #4
I often use plain html controls, not asp.net controls.
so an IMG can not understand the virual root tilde (~) and therefore
resoulveurl() will help

< IMG SRC='<%= ResolveURL(.... etc..

Also!! .. i use it to redirect and always use the root with subfolders for
redirect.
Unless the page is in the same folder.
I don't like to use ..\folder\page.aspx

"SandyIsCool" <sa*************@gmail.comschreef in bericht
news:11**********************@n67g2000cwd.googlegr oups.com...
Hi
Mark.

I used the below code for an image button

image1.imageurl="~/images/image1.jpg";
image1.imageurl=Page.ResolveUrl("~/images/image1.jpg");

Both statements work fine..
I want to see a case where resolveURL method makes a difference.
Thanks,
Sandeep

SandyIsCool wrote:
>Thanks a lot Mark. That really helped this novice.
Thanks again.
Sandy

Mark Fitzpatrick wrote:
The ResolveUrl method is designed to create a friendly URL for a given
resource. For example, when you have a control that references an
image,
you'll want the image to be referenced correctly when that control is
placed
within a page. The ResolveUrl will create the url in a friendly way
that is
relative to the page instead of relative to the control.

The Server.MapPath is used to find the file system path for a given
resource. For example: Server.MapPath("web.config") may give something
like
c:\inetpub\wwwroot\web.config. It's used when you're trying to work
with
files from the server's file system, such as saving uploaded files,
creating
files on the server, referencing file-based databases.
--

Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006
"SandyIsCool" <sa*************@gmail.comwrote in message
news:11**********************@79g2000cws.googlegro ups.com...
Hi,

Can any one let me know what is difference between Server.mappath and
Page.resolveURL and what are the situations we use them.

Thanks,
Sandy

Dec 15 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Glenn M | last post by:
I have a shared XML file on a server . i also have one xslt file that performs a simple transform on in to view the data. now i want to have another page that lets users modify the shared xml...
6
by: darrel | last post by:
I have some functions that are reading/writing to the file system. As such, they use server.mapPath a lot to navigate it all. Since I'm using these functions numerous times throughout my...
7
by: benoit | last post by:
Hi, if I write this code to retrieve a folder on the server Server.mappath("/DATA") I get this error message System.InvalidOperationException: Failed to map the path '/DATA' the virtual...
14
by: Lorenzo | last post by:
Hello, I have a web application with a virtual directory in it. With 'virtual directory' i mean a folder whose physical path is different from the physical path of the application, but in which...
7
by: Tina | last post by:
I'm using 1.1/vs.net 2003 ... C#example.............. string myPath = Server.MapPath(".\\Data\\" + (string) Session); Produces this value in myPath ?myPath
7
by: teo | last post by:
I need to use the 'Server.MapPath' function in the 'Session_End' event of the Global.asax file (to reach a folder and the clean some temporary files up), but it doesn't work: Sub...
1
by: ats | last post by:
Hi there. I have a folder named reports on my web server. Inside the folder is a page named reports.aspx and 2 folders named client1 and client2. I have some spreadsheets in each of the folders...
6
by: withers | last post by:
If I run Server.MapPath("/") on my operational Internet server I get, correctly, the physical path to the directory my page is in (d:\.... \...\htdocs). If I run Server.MapPath("/") on my...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.