473,473 Members | 1,881 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Need help with URI path

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.
Dec 8 '06 #1
4 1863
when a relative url starts with /, that means start from the hostname,
not the current dir.

say your url is

http://myhost.com/mysite/mypage.aspx

then the browser

/img/img.gif will resolve to http://myhost.com/img/img.gif

img/img.gif will resolve to http://myhost.com/mysite/img/img.gif
-- bruce (sqlwork.com)
John Smith wrote:
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.
Dec 8 '06 #2
Right. I forgot to mention I tried that too. But the problem this one is
that I think this is relative to the .css file and not to the .aspx
file. And while it works using the "Build Style..." menu item and
created exactly that, when run it couldn't recognize it (me thinks
probably) because it resolves to:
http://localhost:port/projectLabel/_...imgs/image.jpg, instead of
the expected:
http://localhost:port/projectLabel/imgs/image.jpg

Thank you still.
`Js.
Adriano .NET wrote:
It looks like in your .css file you have the first slash of the image path
unneeded.
Try this:
background: url(imgs/image.jpg) no-repeat 0% 100%;

instead of:
background: url(/imgs/image.jpg) no-repeat 0% 100%;

When you're building a style using VS2005 and you've got some problems like
this just try to right click inside the style definition of the css file and
select Build Style... and every single little issue disappear after you
confirm.

For me it's perfectly working.

Regards, Adriano Palmieri.

"John Smith" wrote:

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

Dec 9 '06 #3
Right. I forgot to mention I tried that too. But the problem this one is
that I think this is relative to the .css file and not to the .aspx
file. And while it works using the "Build Style..." menu item and
created exactly that, when run it couldn't recognize it (me thinks
probably) because it resolves to:
http://localhost:port/projectLabel/_...imgs/image.jpg, instead of
the expected:
http://localhost:port/projectLabel/imgs/image.jpg

Thank you still.
`Js.
Adriano .NET wrote:
It looks like in your .css file you have the first slash of the image path
unneeded.
Try this:
background: url(imgs/image.jpg) no-repeat 0% 100%;

instead of:
background: url(/imgs/image.jpg) no-repeat 0% 100%;

When you're building a style using VS2005 and you've got some problems like
this just try to right click inside the style definition of the css file and
select Build Style... and every single little issue disappear after you
confirm.

For me it's perfectly working.

Regards, Adriano Palmieri.

"John Smith" wrote:

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

Dec 9 '06 #4
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 :)
bruce barker wrote:
when a relative url starts with /, that means start from the hostname,
not the current dir.

say your url is

http://myhost.com/mysite/mypage.aspx

then the browser

/img/img.gif will resolve to http://myhost.com/img/img.gif

img/img.gif will resolve to http://myhost.com/mysite/img/img.gif
-- bruce (sqlwork.com)
John Smith wrote:
>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.
Dec 9 '06 #5

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

Similar topics

5
by: deko | last post by:
In regard to running php scripts with cron - Here is a sample script: <?php //debug.php echo "<br> This is a test"; ?> I can call debug.php from a web page on my site like this:
7
by: Timothy Shih | last post by:
Hi, I am trying to figure out how to use unmanaged code using P/Invoke. I wrote a simple function which takes in 2 buffers (one a byte buffer, one a char buffer) and copies the contents of the byte...
5
by: sling blade | last post by:
I have developled my first major app and i am trying to deploy it in to a host server for publication. However the app tries to use the physical path used during development. Is the path...
5
by: BK-Chicago | last post by:
I am in the midst of porting a massive MFC application from VS6.0 to VS8.0. While i have fixed most of the compile time errors, i do have quite a linker error that i have not been able to resolve....
15
by: Gan Quan | last post by:
I'm writing a c++ program that has many (100+) threads read/write files simultaneously. It works well if not considering the efficiency. The file i/o seems to be the bottleneck. This is my code...
46
by: Bruce W. Darby | last post by:
This will be my very first VB.Net application and it's pretty simple. But I've got a snag in my syntax somewhere. Was hoping that someone could point me in the right direction. The history: My...
5
by: fade | last post by:
Good afternoon, I need some advice on the following: I've got a class that has a member std::vector<CStringm_vFileName and a member CString m_path; The vector contains a bunch of filenames with...
10
by: xxxx | last post by:
Hi all, i need some help here plz :) i'm building a small application that will dispaly a list of folders in a listbox, but i only want to display the folder name rather than the whole path, so...
7
imrosie
by: imrosie | last post by:
Hello, I don't completely understand the working of these functions, but it's been suggested that these will give me what I need. I have a database that pulls in image files (stores the...
5
by: Justin | last post by:
Here's my XML: <?xml version="1.0" ?> <AppMode Type="Network"> <CurrentFolder Path="c:\tabs"> <Tabs> <FilePath>tabs\Justin.tab</FilePath> <FilePath>tabs\Julie.tab</FilePath> *****There could...
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...
1
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.