Re: Page and Images not found on Localhost



Wow George,

You definitely see the problem I'm having. My project is built almost
entirely from User Controls and MasterPages in different folders. VS 2005
sometimes applies relative paths to images "..\..\images\picture.gif" in the
User Controls (separate folder) and other times "/images/picture.gif".
I didn't know that even images could be declared as server controls. But
here is where it gets sticky. If I use the Style attribute like in
style="backgound-image:url(/images/picture_bg_200.gif)", how do I declare
the image reference as a server control, even though the container might be
declared runat="server". Actually, come to think of it that particular code
is in a table cell, which may not have been declared as a server control.

Also there are Class attributes which contain the same type of CSS syntax.

I designated the "project" folder as an application in IIS. The Login screen
which is in "c:/development/project/accounts/" folder does not display the
images when they are declared as "~/images/picture.gif ", but does display
them as "/images/pipcture/gif".

You can see the source of my confusion.

Thanks.. I have yet to implement the DLL I got from you. I may do that this
morning.


"George Ter-Saakov" <gt-nsp@xxxxxxxxxxx> wrote in message
news:Oh4zwXsVHHA.528@xxxxxxxxxxxxxxxxxxxxxxx
Well, there are 2 problems with this approach.

1. ~/ does not work for images (or any other HTML tag) if they are not
declared as server controls. And to make every image a server control is
simply an overkill.

2. If you are not using absolute path (means the one that starts with / )
then you going to have a problem with the user controls or Master pages
that are used in 2 pages in different subfolders. Which is usually a case
for a mid size project when you try to partition your pages into separate
subfolders.



George.



"Mark Fitzpatrick" <markfitz@xxxxxxxxxx> wrote in message
news:Oe9erHsVHHA.1200@xxxxxxxxxxxxxxxxxxxxxxx
You'll always have to address it as localhost, that simply is the name of
the local loopback adapter and just represents the ip address 127.0.0.1.
When you set the project directory in IIS to be an application, then it
is the root for anything under it. In the scenario where projectA is an
application, but projectB isn't set as an application, the root of
projectA resolves to localhost/projectA. For projectB it would be
localhost since the root application is the first application in the
hierarchy.

You shouldn't need to publish to the root if the links and images are
crafted correctly. For links you'll need to either use completely
relative, or use the ~/ to denote it as relative to the application root,
but also you must make sure that the runat="server" attribute is set. A
URL such as /images tells it to use the root from the domain name or IP
address, not the root from the application.


--

Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006
"John Kotuby" <johnk@xxxxxxxxxxxxx> wrote in message
news:%23%23qmAgrVHHA.600@xxxxxxxxxxxxxxxxxxxxxxx
Mark,

Thanks again...

I created an application in IIS manager for the c:\Development\Project
virtual web folder and the application name came back as "Project".

I still need to reference http://localhost/project to get to the default
page, it appears. And still the links are broken.

Should I be able to access the site now without using "localhost" in the
URL, or does creating an application set the Root of the site as the
"Project" folder?

It seems that VS2005 is still looking at //localhost as the Root folder.
Driving me nuts... but I can continue to work by publishing the site to
the root of another IIS server in the office.

... John

"Mark Fitzpatrick" <markfitz@xxxxxxxxxx> wrote in message
news:urnzIzqVHHA.1200@xxxxxxxxxxxxxxxxxxxxxxx
Keep in mind, a virtual directory doesn't make it the root of a site.
You have to ensure that your directory is marked as an application. To
do this go into the management control console (MMC) for IIS. Find the
directory, right-click on it and select properties. Make sure that
under the Home Directory there is an application created in the
Application Settings area. If not, click the create application button.

ASP.Net doesn't care what the directory is, but if it's not marked as
an application it looks to the root application or the one immediately
above it for URL references as well as the bin directory.


--

Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006

"John Kotuby" <johnk@xxxxxxxxxxxxx> wrote in message
news:%23TTLloqVHHA.1552@xxxxxxxxxxxxxxxxxxxxxxx
Hi all,

Maybe this is a simple problem found in ASP.NET 2.0 course 101, but I
must have missed it. When I create a page in Visual Web Developer and
use URLs like "/images/picture.gif " or a link like <a
href="../../Search/page.aspx">,
everything works fine as long as I publish the site to a root web like
http://localhost.

However, I am developing on my local C drive in
c:\development\project. I have created a virtual web site from that
folder in IIS. To access it I type in http://localhost/project.

Here's the problem. When I try to either run the website in IE7 using
http://localhost/project or debug the website from within VS2005,
either on the "default site" or the selected site
http://localhost/project, I lose all my images, stylesheets and even
end up with broken links. But on a Root website evrything is fine.

For example I get 404 File not found
http://localhost/search/page.aspx, when the resource is actually at
http://localhost/project/search/page.aspx.

I have tried using "~/images/picture.gif" and that doesn't work
either... same with the URL paths.

Somebody said I had to create a virtual Domain out of the
c:\development\project folder, but I don't know what he meant. Also,
it takes forever to "publish' the website to the root server. It would
be so much faster if I could just debug in the development folder
right after making and compiling a change.

Thanks to all....











.