views:

257

answers:

1

Is there an alternative, other then modifying HOSTS to setup temp domains when testing websites locally? I'm using IIS7 on Win7.

I don't want to use /localhost/domainname. I'd rather do /domainname so i don't have to worry about paths to files, etc. My websites are setup so that paths to files are relative to the root folder and not to the page.

+1  A: 

Unless your code explicitly checks the domain name, you should be able to deploy on II7 and test through http://localhost.

There are few caveats with this approach, though:

  • if you are using third-party API that requires a key tied to the domain name of you app, you might have to request two keys - one for the domain name (for PROD purposes) and one for localhost (for DEV purposes). I do that with both Google Ajax API and Facebook Connect keys.
  • http://localhost is in different security zone in IE than regular internet sites, so if your app uses any AP that requires cross-domain communication (like Facebook Connect), you might have problems testing on IE7. Works like a charm on Chrome and seems to work properly on IE8.
  • if you are working on multiple apps at the same time, you can't have all of them listen on port 80 at the same time. SO, some of the apps will have to be moved to http://localhost:8080 or another port.

My approach is to run the VS Dev WebServer (Cassini) on ports 808x during developing and to deploy to the local IIS7 (using CruiseControl.Net) on ports 888x. This allows me to debug easily with VS while working on the code, yet still have the site set under medium trust on IIS7.

I also have a host name on the target domain pointing to my dev machine, so the IIS7 instances are available both as http://localhost:888x and http://dev.domain.com:888x, which allows me to also test the domain integration with Google Ajax and Facebook Connect APIs. Of course, this requires control over the domain DNS and the ability to add an A record to it.

However, note that nothing in this setup requires actual testing on the domain URL.

Franci Penov
Every site on different ports is the easiest way to go - and +1 for pointing out interesting caveats.
Filburt
I like what your saying. Because I'm working on several sites at the same time I was hoping to not have to change localhost in IIS to point to a different server each time I want to test a site before deployment. However, in retrospect maybe that's my solution. I do .net and php projects in dreamweaver so was looking for a solution that would work for both. Cassini is the BEST option for .Net though I completely agree.
Jason Shultz
Just use different ports and deploy both solutions as IIS7 websites - your .Net to http://localhost:8881 and your PHP on http://localhost:8882. This way you can have both running at the same time.
Franci Penov
that's a great idea! Thanks. :)
Jason Shultz