Isolated Development model problems

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
 
K

Kevin Spencer

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.
 
G

Guest

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.
 
J

John Saunders

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" >
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top