Why do people host with IIS? And why is ASP still around?
At any rate, it is. So if you need to migrate a site from one domain to another and it's hosted on IIS, here's a way to do it:
Replace every page on the old site with the following code:
<%
OriginalURL = Request.ServerVariables("URL")
RedirectURL = "http://www.NEWDOMAIN.com" & OriginalURL
Response.Status="301 Moved Permanently"
Response.AddHeader "Location", RedirectURL
%>
The typical examples you'll see on most web sites redirect all pages to a single, new URL -- this is not what you want to do, if you care about search engine rankings. Fancy games with the 404 error page don't really work so well for a page-wise redirect, either, because IIS strips the referer and the URL is the 404 error page by the time any script runs there, so you'd have to be playing games with each individual page anyway. And as long as you're doing that, you might as well plug in the above code instead of settings cookies or session variables and then reading them from the special 404 page.
Anyway, I don't care if this all makes sense to you because I wrote it so I'd remember next time I need to do it. Yay!