Need help with URI path

J

John Smith

Hello,

I'm not sure if these are the appropriate forums for my question since
it is closer to about Visual Studio 2005 than it is about .NET
framework. So please pardon me and direct me to a different forum if I
made a mistake. In any case, thank you for spending the time to read
this loooong case and/or for your input.

With that said, here's the background of the situation:

----- Scenario -----
I have created a web project using VS2005.
The file structure as seen from the /Solution Explorer/ is as the following:
- Solution label/filename/location
- Project label/filename/location
- App_Code
- css
- style.css
- imgs
- image.jpg
- js
- script.js
- main.aspx

The content of style.css in discussion is:
/*----- CSS -----*/
.StyleClassName
{
background: url(/imgs/image.jpg) no-repeat 0% 100%;
font-size: 10pt;
}
/*----- End CSS Excerpt -----*/

The content of main.aspx in discussion is:
/*----- ASP.Net -----*/
<link rel="stylesheet" media="all" type="text/css"
href="css/style.css" />
...
<div id="div1" class="StyleClassName">Test</div>
/*----- End ASP.Net Excerpt -----*/

Everything is dandy, except for the image not displaying.
----- End Scenario -----

The question is:
- How can I configure Visual Studio, so that when I click Build/Start
(F5) the image displays according to its path designation (from the web
root)?

What I've tried:
- I tried hard coding the path into the URL descriptor, e.g.: changing
(/imgs/image.jpg) to
(http://localhost:port/projectLabel/imgs/image.jpg). This works, but I
don't like having to remember to change the hard code back when I
publish to the real IIS server (which has no problem with the original
descriptor) and back again when I continue coding.
- The original path is relative to the application web root, a practice
which I very much like, since the root is usually the only constant in a
web project. But for this purpose, I even tried using (imgs/image.jpg)
for kicks, but doesn't work. Also tried a few others like
(../imgs/image.jpg), (../../imgs/image.jpg), (/../imgs/image.jpg), and
(/../../imgs/image.jpg), one of them (the 1st) works, but it isn't
semantically correct when published again with a different root
directory, right? It's like saying, "Go back up one, two or three
directory levels to try to find the web root then from the web root find
imgs/image.jpg," instead of just saying: "you know where the root is,
from there find imgs/image.jpg." I mean I would be forced to do this
anyway if there's no answer to this question.

In VS.2003 or earlier this wasn't have been a problem since the IIS
application directory is setup to start at the project directory, so
that the web root follows the server's definition. (There were other
problems I realize but that's a different topic).

So... Is there a way to configure the IDE with a single-click option so
that it /works/ as expected? (Other than of using the "Use custom
Server, then start specifying everything manually again to mimic VS.2003
IIS setup).

Thanks again.
`Js.
 
J

John Smith

J

John Smith

J

John Smith

Oops... btw, sorry for the duplicate response on the other post,
double-clicked send by accident (instead of one click).
Yes, Bruce, I understand that when I used the slash it means it starts
from the webroot.
In regular IIS (Windows Server) installation the webroot happens to be
the hostname, and for the Windows XP workstation version the webroot
happens to be the application directory, and thus it /could (and usually
does)/ resolve to:
http://localhost/appDirectory/imgs/image.jpg.

But in the case for VS2005, for some reason it resolves back to the
hostname as you indicated and is not the sought effect since when it
resolves to the hostname it actually resolves to:
http://localhost:port/imgs/image.jpg.
instead of the expected:
http://localhost:port/projectLabel/imgs/image.jpg
I didn't want this during development with VS2005 (since the IDE is
mostly nifty and all :))

But when I publish to the actual Windows Server IIS installation, yes, I
am ok with it resolving to:
http://domainName/imgs/image.jpg
since that is how the it's supposed to work anyway.

As far as trying with relative path of just img/image.jpg, please see my
other response about its observed resolution.

Thank you for your input.
`Js.

PS. I tried with numerous combination of slashes and up-dir-double-dots
not because I didn't know the slash theory/concept :) but because the
IIS and VS.NET behaviors don't seem to follow the expected standard
behaviors. We all know that Microsoft often does things a bit
differently than the standard, but still, since I am not a Microsoft
basher, I thought maybe it's just my ignorance of the way the IDE is
supposed to be configured. :p :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top