tags:

views:

843

answers:

4

The site I'm working on is done in Classic ASP, and I'm trying to do it as best as possible. I've abstracted it out into a Rails-like directory structure:

app_name
 - app
   - includes
     - helpers
     - lib
     - partials
  - public
    - stylesheets
    - images
    - javascripts

I've created some Rails-like helpers, for example:

Function ImageTag(ByVal imageFileName, ByVal altText)
  path = Server.MapPath(IMAGE_ROOT & imageFileName & ".jpg")
  ImageTag = "<img src=""" & path & """ title=""" & altText & """ alt=""" & altText & """ />"
End Function

Which is used thusly:

<%= ImageTag("my_pic") %>

With "IMAGE_ROOT" defined as "../public/images/" in a config file. I'm doing development on XP so the site is set as a virtual directory. However, the image won't load on the webpage at all. It's displaying the right path to it, because I can copy/paste it into my browser and view the image - it just won't display on the page for some reason. The same thing goes for my CSS stylesheet - the path is right but the page isn't rendering it at all.

Any suggestions?

A: 

-Could it be an issue with the generated html?
-You might want to try making IMAGE_ROOT an absolute path like "/public/images" instead of the relative one (if possible).
-Also you could look at the IIS logs to see if you're getting 404 errors for the images and css files.

Kevin Tighe
+1  A: 

You're probably going to run into issues mixing server-side and web directories.

Server.MapPath will give you C:\InetPub\...\public\images\my_pic.jpg when you probably want /public/images/my_pic.jpg. The browser has no way of grabbing the first from your server.

The image has to be available via your domain: localhost/public/images/my_pid.jpg.


I assume, since you can view the image, that you're developing on the same box that's hosting it? If that's the case, you can view the image cause it's just opened as a local file by the browser. Everyone else has to use HTTP-only.

Jonathan Lonowski
A: 

An excellent tool to use when troubleshooting these types of issues is Fiddler. It will show you the calls and responses directly bewtween your web browser and the server. It works out of the box with IE and FireFox support is just a config setting away.

I'ver personally used Fiddler to track down image load issues, CSS problems, caching issues, redirect errors, and even have used it to tamper with URL variables to try breaking/hacking my sites.

Fiddler Website

NewCom
A: 

If app_name/app is the root of your IIS-site then you must at app_name/app as a virtual directory in your IIS site. As it is only static content there you do not need to permissions to execute .asp scripts either.

Espen