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.
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.