473,385 Members | 1,402 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Page and Images not found on Localhost

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....
Feb 22 '07 #1
12 3815
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" <jo***@powerlist.comwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
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....

Feb 22 '07 #2
re:
"/images/picture.gif"
I have tried using "~/images/picture.gif" and that doesn't work either...
"~/images/picture.gif" does work...

That will resolve to the right directory whether you're in the root app or in a subdirectory,
provided the directory exists within the application, of course.

You cannot use the root directory's images directory for virtual apps.

Each app should have its own images directory, and using "~/images/picture.gif"
will resolve the correct path to the application's images directory.

The same is valid for other application directories as well.


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"John Kotuby" <jo***@powerlist.comwrote in message news:%2****************@TK2MSFTNGP05.phx.gbl...
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....

Feb 22 '07 #3
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" <ma******@fitzme.comwrote in message
news:ur**************@TK2MSFTNGP04.phx.gbl...
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" <jo***@powerlist.comwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
>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....


Feb 22 '07 #4
Yep, This is such problem.

When you developing your application it's usually a subfolder on your local
IIS. But when you move to production it usually works of the root of the
IIS.

I have developed an ISAPI dll that helps me with that problem

basically what it does is maps your project name to the folder. So when you
hit
http://myproject/mypage.aspx it hits in reality
http://localhost/mypoject/mypage.aspx
You will need to make some changes to your windows HOSTS file so the name
myproject becomes available.

Read more and get that DLL from
http://www.codeproject.com/aspnet/Multisite.asp

You will need to invest a bit time into reading the article on how to setup
DLL correctly but in the end it works like a charm.
George.

"John Kotuby" <jo***@powerlist.comwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
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....

Feb 22 '07 #5
Yep, There is such problem.

When you developing your application it's usually a subfolder on your local
IIS. But when you move to production it usually works of the root of the
IIS.

I have developed an ISAPI dll that helps me with that problem

basically what it does is maps your project name to the folder. So when you
hit
http://myproject/mypage.aspx it hits in reality
http://localhost/mypoject/mypage.aspx
You will need to make some changes to your windows HOSTS file so the name
myproject becomes available.

Read more and get that DLL from
http://www.codeproject.com/aspnet/Multisite.asp

You will need to invest a bit time into reading the article on how to setup
DLL correctly but in the end it works like a charm.
George.

"John Kotuby" <jo***@powerlist.comwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
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....


Feb 22 '07 #6
Yep, There is such problem.

When you developing your application it's usually a subfolder on your local
IIS. But when you move to production it usually works of the root of the
IIS.

I have developed an ISAPI dll that helps me with that problem

basically what it does is maps your project name to the folder. So when you
hit
http://myproject/mypage.aspx it hits in reality
http://localhost/mypoject/mypage.aspx
You will need to make some changes to your windows HOSTS file so the name
myproject becomes available.

Read more and get that DLL from
http://www.codeproject.com/aspnet/Multisite.asp

You will need to invest a bit time into reading the article on how to setup
DLL correctly but in the end it works like a charm.
George.

"John Kotuby" <jo***@powerlist.comwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
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....

Feb 22 '07 #7
Ray
Just remove the forward slash that you have there before
"images", so it goes based on the existing directory structure
instead of the root.

"John Kotuby" <jo***@powerlist.comwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
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....


Feb 22 '07 #8
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" <jo***@powerlist.comwrote in message
news:%2*****************@TK2MSFTNGP05.phx.gbl...
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" <ma******@fitzme.comwrote in message
news:ur**************@TK2MSFTNGP04.phx.gbl...
>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" <jo***@powerlist.comwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
>>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....



Feb 22 '07 #9
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" <ma******@fitzme.comwrote in message
news:Oe**************@TK2MSFTNGP04.phx.gbl...
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" <jo***@powerlist.comwrote in message
news:%2*****************@TK2MSFTNGP05.phx.gbl...
>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" <ma******@fitzme.comwrote in message
news:ur**************@TK2MSFTNGP04.phx.gbl...
>>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" <jo***@powerlist.comwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl.. .
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....



Feb 22 '07 #10
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****@cardone.comwrote in message
news:Oh*************@TK2MSFTNGP03.phx.gbl...
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" <ma******@fitzme.comwrote in message
news:Oe**************@TK2MSFTNGP04.phx.gbl...
>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" <jo***@powerlist.comwrote in message
news:%2*****************@TK2MSFTNGP05.phx.gbl.. .
>>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" <ma******@fitzme.comwrote in message
news:ur**************@TK2MSFTNGP04.phx.gbl...
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" <jo***@powerlist.comwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl. ..
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....
>




Feb 23 '07 #11
Yep, as i said pretty much any mid size project going to have problems like
that. And i happened to work on couple like that.

Anyway fee free to hit my email if you have any question about my
multisite.dll.
My email ge******@comcast.net (remove dollar signs)
George

"John Kotuby" <jo***@powerlist.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
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****@cardone.comwrote in message
news:Oh*************@TK2MSFTNGP03.phx.gbl...
>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" <ma******@fitzme.comwrote in message
news:Oe**************@TK2MSFTNGP04.phx.gbl...
>>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" <jo***@powerlist.comwrote in message
news:%2*****************@TK2MSFTNGP05.phx.gbl. ..
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" <ma******@fitzme.comwrote in message
news:ur**************@TK2MSFTNGP04.phx.gbl...
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" <jo***@powerlist.comwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl.. .
>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....
>>
>
>




Feb 23 '07 #12
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
theimagereferenceas 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.

Here's what I do:

In my user control I write a simple function which returns the
application path and the location of the images:

Function GetAppPath() As String
Dim str As String
str = Request.ApplicationPath & "/images/"
Return str
End Function

Then, in the case of a background image for a table or table cell, I
declare that cell as a server control and give it an ID (obviously).

The page_load for that control, I set the CSS style

menubackground.Style.Value = "background-Image:url(" & GetAppPath() &
"menu_grad1.gif)"

Pain in the ass, yes, but you only have to write it once.

Microsoft really needs to fix this. It needs to be smart enough to
know that when you use a user control which is located in a different
folder from the web form, that the references to the images in the
user control change.

Apr 12 '07 #13

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

Similar topics

7
by: Jacob | last post by:
Has anybody else encountered a problem when running your asp.net applications off your localhost and having broken image links? The weird thing is, the links aren't really broken. The reference...
4
by: Bernie Raffe | last post by:
When I change the 'cookieless' flag in the WebConfig file to true, everything works fine on my local PC, but the images fail to appear when using the remote server. I specify my images...
3
by: Brett Baisley | last post by:
Hello, I am having trouble figuring out URL's from my master page. Here is my setup. I have a default.aspx and default.master file in the root folder. I have an "images" folder with logos and...
2
by: Mongkon | last post by:
I use Visual studio.net 2003 for develop a web application by communicate with Web service (it has been developed by Java) and I has added web reference but It can’t to and show error message...
1
by: vj | last post by:
How i can populate all fileds dynamically in jsp page based on contents found in xml file? I have written jsp servlets and java class file. i transferred automatic data from jsp to servlet then to...
23
by: Peter | last post by:
I have a problem with a page show_image.asp that returns a jpg image under Windows XP Pro SP2. The page sets content type as: Response.ContentType = "image/jpg" While this works perfectly fine...
8
by: rn5a | last post by:
I have a HTML page named Index.html which is divided into 3 frames. The URL of 2 of the frames are HTML pages but the 3rd frame houses a ASP page. Now when I go to Windows Explorer, navigate to...
4
by: sid | last post by:
Can someone tell me how to detect "Action Cancelled" page with out polling. I have a frame set and I want to make sure the other frame is displaying what it is supposed to without polling. For...
8
by: Cirene | last post by:
I have 1 master page in the root of my website that I would like to share with all pages, even those in my /admin and /client directories. But when pages in the subdir's are viewed the img, css,...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.