List Info

Thread: VS.NET, Default Web Site, and relative paths...




VS.NET, Default Web Site, and relative paths...
user name
2006-12-14 09:23:45
Morning all.

I am developing a website in VS.NET 2005 on an XP machine
and by
default it has created the site under the Default Web Site
on the
local machine.  When I run my app within VS.NET or browse it
mnually I
find it at the following address:

http://localhost/
myapp/default.aspx

Within my application I reference other pages using the
syntax
"/myapp/blah/blah/blah" - (such as the main menu
at the root, the
images folder, and various other shared resources).

This works fine locally and in the development stages, but
when in
production the website will not live under a /myapp folder
from the
Default Web Site root - it will be a new website.

This causes a problem with referencing the site root as
"/myapp".

I'd like to find a solution that works in both situations
without
making any code changes when I put the site into production.

Any help or thoughts appreciated.

Cheers,

Ben

===================================
This list is hosted by DevelopMentorŪ  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

VS.NET, Default Web Site, and relative paths...
user name
2006-12-14 09:36:47
Use ~/ as your root.

Thus instead of linking to /myapp/default.aspx
you should link to ~/default.aspx

HTH
// Ryan

On 12/14/06, Ben Joyce <ben.joycegmail.com> wrote:
> Morning all.
>
> I am developing a website in VS.NET 2005 on an XP
machine and by
> default it has created the site under the Default Web
Site on the
> local machine.  When I run my app within VS.NET or
browse it mnually I
> find it at the following address:
>
> http://localhost/
myapp/default.aspx
>
> Within my application I reference other pages using the
syntax
> "/myapp/blah/blah/blah" - (such as the main
menu at the root, the
> images folder, and various other shared resources).
>
> This works fine locally and in the development stages,
but when in
> production the website will not live under a /myapp
folder from the
> Default Web Site root - it will be a new website.
>
> This causes a problem with referencing the site root as
"/myapp".
>
> I'd like to find a solution that works in both
situations without
> making any code changes when I put the site into
production.
>
> Any help or thoughts appreciated.
>
> Cheers,
>
> Ben
>
> ===================================
> This list is hosted by DevelopMentor(r)  http://www.develop.com
>
> View archives and manage your subscription(s) at http://discuss.develop.com

>

===================================
This list is hosted by DevelopMentorŪ  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

VS.NET, Default Web Site, and relative paths...
user name
2006-12-14 09:36:47
Hi Ben,

It depends on where you referenced those pages, images, etc.
The
majority of ASP.Net server controls supports the tilde (~)
notation for
url references, expanding it to the root of the app they are
instantiated into; so, if your references are inside server
controls you
should be (almost) fine.

For example:

<asp:Image runat="server"
ImageUrl="~/Images/MyImage.jpg" />
and
<img runat="server"
src="~/Images/MyImage.jpg" />
will both point to the MyImage.jpg file, inside the Images
subfolder,
related to the root of your web app, no matter if it lives
in a virtual
directory (so both your development and production
environment will be ok).

Css style sheets are a different beast; they let you use
urls (for
background images, for example) relative to where the css
reside. So, if
your css is in the ~/Styles subfolder and you want to
reference the
aforementioned MyImage.jpg file you should use:

background-image: url("../Images/MyImage.jpg");

HTH,

Efran Cobisi
http://www.cobisi.com

Ben Joyce wrote:
> Morning all.
>
> I am developing a website in VS.NET 2005 on an XP
machine and by
> default it has created the site under the Default Web
Site on the
> local machine.  When I run my app within VS.NET or
browse it mnually I
> find it at the following address:
>
> http://localhost/
myapp/default.aspx
>
> Within my application I reference other pages using the
syntax
> "/myapp/blah/blah/blah" - (such as the main
menu at the root, the
> images folder, and various other shared resources).
>
> This works fine locally and in the development stages,
but when in
> production the website will not live under a /myapp
folder from the
> Default Web Site root - it will be a new website.
>
> This causes a problem with referencing the site root as
"/myapp".
>
> I'd like to find a solution that works in both
situations without
> making any code changes when I put the site into
production.
>
> Any help or thoughts appreciated.
>
> Cheers,
>
> Ben
>
> ===================================
> This list is hosted by DevelopMentorŪ  http://www.develop.com
>
> View archives and manage your subscription(s) at
> http://discuss.develop.com


===================================
This list is hosted by DevelopMentorŪ  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

VS.NET, Default Web Site, and relative paths...
user name
2006-12-14 15:13:06
Ben,

I know exactly what you're talking about, and there is any
easy way
around it. I haven't used .NET for some time, but I just did
this on my
machine.

Instead of entering "http://localhost/",
just delete the trailing slash
so you have "http://localhost"

Thanks,
Jordan

===================================
This list is hosted by DevelopMentorŪ  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

VS.NET, Default Web Site, and relative paths...
user name
2006-12-21 08:33:02
Hi all.  Thanks for the replies, I trawled through my
application
making all the required changes.

It's a bit frustrating; I can use the ~/ in client-side
paths for CSS
for not for JavaScript files, also it does not work for IMG
tags but
does for the server-controls.

Oh well.

Ben

On 12/14/06, Fritts,Jordan <JFrittslearn.colostate.edu>
wrote:
> Ben,
>
> I know exactly what you're talking about, and there is
any easy way
> around it. I haven't used .NET for some time, but I
just did this on my
> machine.
>
> Instead of entering "http://localhost/",
just delete the trailing slash
> so you have "http://localhost"
>
> Thanks,
> Jordan
>
> ===================================
> This list is hosted by DevelopMentor(r)  http://www.develop.com
>
> View archives and manage your subscription(s) at http://discuss.develop.com

>

===================================
This list is hosted by DevelopMentorŪ  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

VS.NET, Default Web Site, and relative paths...
user name
2006-12-21 10:37:48
In web pages/controls code, you can use
ResolveUrl("~/yourpath") too.

HTH
// Ryan

On 12/21/06, Ben Joyce <ben.joycegmail.com> wrote:
> Hi all.  Thanks for the replies, I trawled through my
application
> making all the required changes.
>
> It's a bit frustrating; I can use the ~/ in client-side
paths for CSS
> for not for JavaScript files, also it does not work for
IMG tags but
> does for the server-controls.
>
> Oh well.
>
> Ben
>
> On 12/14/06, Fritts,Jordan <JFrittslearn.colostate.edu> wrote:
> > Ben,
> >
> > I know exactly what you're talking about, and
there is any easy way
> > around it. I haven't used .NET for some time, but
I just did this on my
> > machine.
> >
> > Instead of entering "http://localhost/",
just delete the trailing slash
> > so you have "http://localhost"
> >
> > Thanks,
> > Jordan
> >
> > ===================================
> > This list is hosted by DevelopMentor(r)  http://www.develop.com
> >
> > View archives and manage your subscription(s) at
http://discuss.develop.com

> >
>
> ===================================
> This list is hosted by DevelopMentor(r)  http://www.develop.com
>
> View archives and manage your subscription(s) at http://discuss.develop.com

>

===================================
This list is hosted by DevelopMentorŪ  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

VS.NET, Default Web Site, and relative paths...
user name
2006-12-21 11:00:18
I suppose I could use an ASP Server Image control for all my
images,
seems a bit of an overkill though.

On 12/21/06, Ryan Heath <ryan.q.heathgmail.com> wrote:
> In web pages/controls code, you can use
ResolveUrl("~/yourpath") too.
>
> HTH
> // Ryan
>
> On 12/21/06, Ben Joyce <ben.joycegmail.com> wrote:
> > Hi all.  Thanks for the replies, I trawled through
my application
> > making all the required changes.
> >
> > It's a bit frustrating; I can use the ~/ in
client-side paths for CSS
> > for not for JavaScript files, also it does not
work for IMG tags but
> > does for the server-controls.
> >
> > Oh well.
> >
> > Ben
> >
> > On 12/14/06, Fritts,Jordan <JFrittslearn.colostate.edu> wrote:
> > > Ben,
> > >
> > > I know exactly what you're talking about, and
there is any easy way
> > > around it. I haven't used .NET for some time,
but I just did this on my
> > > machine.
> > >
> > > Instead of entering "http://localhost/",
just delete the trailing slash
> > > so you have "http://localhost"
> > >
> > > Thanks,
> > > Jordan
> > >
> > > ===================================
> > > This list is hosted by DevelopMentor(r)  http://www.develop.com
> > >
> > > View archives and manage your subscription(s)
at http://discuss.develop.com

> > >
> >
> > ===================================
> > This list is hosted by DevelopMentor(r)  http://www.develop.com
> >
> > View archives and manage your subscription(s) at
http://discuss.develop.com

> >
>
> ===================================
> This list is hosted by DevelopMentor(r)  http://www.develop.com
>
> View archives and manage your subscription(s) at http://discuss.develop.com

>

===================================
This list is hosted by DevelopMentorŪ  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

[1-7]

about | contact  Other archives ( Real Estate discussion Medical topics )