Isolated Development model problems

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

When developing ASP.NET apps using Microsoft's recommended isolated model (develop on your local iis), there are deployement reference problems because the local website is generally one level deeper than the production website.

For example, the local website (running XP Pro) is: http://localhost/webapp. Images are kept in the images subfolder. Because IIS does not recognize subwebs as roots, the local means of refering to an image is /webapp/images/image.jpg. Using /images/image.jpg does not work for the above reason

So when the site is migrated to http://www.webapp.com, the image reference is no longer valid, and needs to be /images/image.jpg, NOT /webapp/images/image.jpg

The only solution I can come up with is to use a server OS on our development machines so we can have multiple web sites. But I really don't want to do this

Is there a better solution
 
Use absolute URLs?

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

John Tacke said:
When developing ASP.NET apps using Microsoft's recommended isolated model
(develop on your local iis), there are deployement reference problems
because the local website is generally one level deeper than the production
website.
For example, the local website (running XP Pro) is:
http://localhost/webapp. Images are kept in the images subfolder. Because
IIS does not recognize subwebs as roots, the local means of refering to an
image is /webapp/images/image.jpg. Using /images/image.jpg does not work for
the above reason.
So when the site is migrated to http://www.webapp.com, the image reference
is no longer valid, and needs to be /images/image.jpg, NOT
/webapp/images/image.jpg.
The only solution I can come up with is to use a server OS on our
development machines so we can have multiple web sites. But I really don't
want to do this.
 
Absolute references won't work because there will be one or even two development and stage servers (http://stage.webapp.com) before getting to production, plus hard-coding the absolute URL invites a big maintenance problem if the URL changes.
 
John Tacke said:
When developing ASP.NET apps using Microsoft's recommended isolated model
(develop on your local iis), there are deployement reference problems
because the local website is generally one level deeper than the production
website.
For example, the local website (running XP Pro) is:
http://localhost/webapp. Images are kept in the images subfolder. Because
IIS does not recognize subwebs as roots, the local means of refering to an
image is /webapp/images/image.jpg. Using /images/image.jpg does not work for
the above reason.
So when the site is migrated to http://www.webapp.com, the image reference
is no longer valid, and needs to be /images/image.jpg, NOT
/webapp/images/image.jpg.
The only solution I can come up with is to use a server OS on our
development machines so we can have multiple web sites. But I really don't
want to do this.
Is there a better solution?

Use site-relative URLs. ~/images/separator.gif will refer to
http://localhost/webapp/images/separator.gif locally, or
http://www.webapp.com/images/separator.gif in production.

The only catch is that only ASP.NET understands these URLs. It translates
them into the appropriate "real" URL when your page is being rendered as
HTML. But ASP.NET can only see controls marked "runat=server". This means
that you need to do things like:

<img runat="server" src="~/images/separator.gif" >
 
Back
Top