Re: Image URL?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Thanks for your reply.

It is works, partially, I would say.
On my development machine, I have this dir structure

c:\Inetpub\wwwroot\MYWEBSITE

On my production machine, I did not put MYWEBSITE under Inetput. I put
it under c:

c:\MYWEBSITE

So my user control's dir is
Dev Server c:\Inetpub\wwwroot\MYWEBSITE\userControls and
Production Server c:\MYWEBSITE\userControls

my image's dir is

Dev Server c:\Inetpub\wwwroot\MYWEBSITE\Images
Production Server c:\MYWEBSITE\Images

Trying to understand the dir completely, I tried the following cases. I
access MYWEBSITE from developement server itself. from a client other
than production server. and from production server itself. And I got
the following result

my understanding is, absolute dir does not work if the production
website is under a different dir than it is on dev server. If it works
on dev server, then it won't work on production server, vise versa.

finally, I go for relative path, I am not sure is it the best solution,
but it works on both dev server and production server.

I really hoped that Request.ApplicationPath + "/Images/sort_asc.gif";
is smart enough to know the application path, but it is not.

Maybe I am missing something?

The folowing shows the ImageUrl used in code behind, the HTML url that
generates and if it works.

imgSort.ImageUrl = "Images/sort_desc.gif"
Dev Server
http://localhost/MYWEBSITE/Controls/Images/sort_desc.gif doesn't work
Client - Production Server
http://WEB_SERVER_NAME/Images/sort_asc.gif Works
Production Server
http://WEB_SERVER_NAME/Images/sort_asc.gif Works

imgSort.ImageUrl = Request.ApplicationPath + "Images/sort_desc.gif";
Dev Server
http://localhost/MYWEBSITEImages/sort_asc.gif doesn't work
Client- Production Server
http://WEB_SERVER_NAME/Images/sort_asc.gif works
Production Server
http://WEB_SERVER_NAME/Images/sort_asc.gif works

imgSort.ImageUrl = Request.ApplicationPath + "/Images/sort_asc.gif";
Dev Server
http://localhost/MYWEBSITE/Images/sort_desc.gif works
Client-Productiion Server
http://images/sort_desc.gif doesn't work
Production Server
http://images/sort_asc.gif doesn't work


imgSort.ImageUrl = "../Images/sort_asc.gif";
DEV SERVER
http://localhost/MYWEBSITE/Images/sort_asc.gif WORKS
Production Server
http://WEB_SERVER_NAME/Images/sort_asc.gif WORKS
Client-Production Server
http://WEB_SERVER_NAME/Images/sort_asc.gif WORKS

Mark Fitzpatrick wrote:
MapPath is only good when you're trying to access the files on the server in
code, for example, when opening an Excel spreadsheet to edit, or to write an
image out. It won't do anything for the client.

You can take the application path, and add the path to the file with it like
so:

imgSort.ImageUrl = Request.ApplicationPath + "/Images/sort_asc.gif";

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage




"rockdale" <rockdale.green@xxxxxxxxx> wrote in message
news:1150767611.701155.112310@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I believe this must be a very sample question.

I have a image dir under myWebsite (myWebSite is the root dir of my web
appl)

I have an ascx file under myWebsite/userControls

in the c# of ascx file, I load a image file using MapPath.

imgSort.ImageUrl = Server.MapPath("Images/sort_asc.gif");

If I check the source from IE

I found that the imgSort's image is c:\myWebsite\sort_asc.gif

It points to my client local c driver and the img does not show up.

Of course if I access myWebsite from server, I got the correct image,
'cause that is the C driver on server.

I tried to use relative path, but got no luck.

How should I point to the image url?

Thanks a lot
-Rockdale


.



Relevant Pages

  • Re: Code Behind vs not
    ... When inline code is deployed to a production server you now have server ... If you have an error during compile time it will occur on the production ...
    (microsoft.public.dotnet.framework.aspnet)
  • RE: Need for deployment project, VS 2008, WinXP
    ... is proper to put into the production server. ... copying updated DLL to Production server works fine. ... In the staging server, create a bat file named "ReinstallWebSetup.bat". ... Microsoft Online Community Support ...
    (microsoft.public.vsnet.general)
  • Re: Performance problems oracle 8i
    ... > processor, less memory). ... The production server should be faster than ... W2K does not support a bulk of memory, ... > But now we're trying the scripts on the production server and it all ...
    (comp.databases.oracle.misc)
  • RE: Help with NAT
    ... When I visit the development server through the FreeBSD NAT box I ... xl1 is the external interface, xl0 is the internal interface, ... And this is what I see when I try the production server: ...
    (freebsd-questions)
  • RE: Deploying Biztalk solution
    ... No need to copy the DLLs manually from the dev server to the prod server. ... solutions / class libraries to the production server and insert them into the ... Open up the Biztalk admin console on your dev server, ...
    (microsoft.public.biztalk.general)