473,761 Members | 8,813 Online
Bytes | Software Development & Data Engineering Community
+ 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="StyleCla ssName">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 1884
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="StyleCla ssName">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="StyleCla ssName">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="StyleCla ssName">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="StyleCla ssName">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
9202
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
3306
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 buffer into the character pointer. The code looks like the following: #include <stdio.h> #include <stdlib.h> #include "stdafx.h" BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call,
5
1818
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 hard coded in my dll or similar file? In trying to nail down exactly where this path is located, I have deleted all files except for the index files, the Global.asax files,
5
3274
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. The error i get is Error 100 error LNK2001: unresolved external symbol "public: virtual void __thiscall CWnd::PostNcDestroy(void)" (?PostNcDestroy@CWnd@@UAEXXZ) Evenout.obj I have about 200 of these on almost all the obj's that have a dialog...
15
3654
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 to read from and write to files: #include <fstream> #include <sstream> #include <string>
46
2533
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 work involves creating custom packages of our software product for golf courses that purchase our software. The course data is kept as a back up in the event the course needs us to replace their custom files. Each course has a folder of it's own...
5
3909
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 no path included (no C:\...) eg: my_file2.jpg, my_file1.bmp, etc... and m_path stores the path, eg: C:\folder1 I want to sort this vector according to different criterion, such as
10
1491
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 i take the substring from the whole path and add it to the listbox. the problem is, later, when the user selects to do anything with this file, i want to get the whole path back(mandatory), but now i only have the the name and not the path.
7
3760
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 absolute path in database). The image shows up in my subform. The file name is displayed in a form control called 'image description'. The problem is it displays the entire link, such as c:\imageCats\GizmotheCat.jpg (absolute path).... End user cah...
5
2162
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 be 1 of these or 100....quantity can change***** </Tabs>
0
9554
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9376
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10136
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9923
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8813
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7358
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6640
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2788
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.