Re: VS.NET, Default Web Site, and relative paths...
Scott Guthrie <[email protected]>
| Newsgroups | gmane.comp.windows.devel.dotnet.web |
|---|---|
| Message-ID | <677CFAA281B35A48BF00D300D7C0CBB108F9CDE571@NA-EXMSG-C106.redmond.corp.microsoft.com> |
If you want to support absolute paths, for example:
<script src="/scripts/my.js"></script>
You can use this new feature of VS 2005 SP1 that I blogged about yesterday: http://weblogs.asp.net/scottgu/archive/2006/12/19/tip-trick-how-to-run-a-root-site-with-the-local-web-server-using-vs-2005-sp1.aspx This enables you to run the built-in VS web-server as a root web-site.
Alternatively, you can convert the web-site from being a file-system to an HTTP web-site and run it that way: http://weblogs.asp.net/scottgu/archive/2005/08/23/423409.aspx
Hope this helps,
Scott
-----Original Message-----
From: Discussion of building .NET applications targeted for the Web [mailto:[email protected]] On Behalf Of Mark Kucera
Sent: Thursday, December 21, 2006 5:51 AM
To: [email protected]
Subject: Re: [DOTNET-WEB] VS.NET, Default Web Site, and relative paths...
The ~/ will work for HTML controls as long as you add runat="server" to
the control. Usually whenever I add runat="server" to a control just so
that I can use ~/ then I also make sure to add EnableViewState="false".
The problem that you'll notice is that this works great for images and
hyperlinks when used with the traditional <a> or <img> tags. The method
breaks down in table cells or any control that allows you to specify
background images. i.e.
<td runat="server" enableviewstate="false"
background="~/images/background1.gif"></td>
This example won't work.
There are a couple of other items that won't work by adding
runat="server", notably client side <script> tags the reference a js
file, because adding runat="server" to a client side script tag gives
the control a whole new meaning. i.e.
<script language="javascript" src="~/scripts/my.js"></script>
Also you'll have problems w/ <link> tags that reference .css style
sheets.
Hopefully this might help you some. At least you won't have to convert
all your <IMG> to <asp:Image> and <a href> to <asp:HyperLink> tags...
Good Luck
MK
-----Original Message-----
From: Discussion of building .NET applications targeted for the Web
[mailto:[email protected]] On Behalf Of Ben Joyce
Sent: Thursday, December 21, 2006 6:00 AM
To: [email protected]
Subject: Re: [DOTNET-WEB] VS.NET, Default Web Site, and relative
paths...
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 <[email protected]> wrote:
> In web pages/controls code, you can use ResolveUrl("~/yourpath") too.
>
> HTH
> // Ryan
>
> On 12/21/06, Ben Joyce <[email protected]> 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 <[email protected]> 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(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
===================================
This list is hosted by DevelopMentor® http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com