tags:

views:

2352

answers:

5

For my IIS website, I'd like to redirect ALL requests to ONE page. The purpose of this is that I want to do some maintenance on the database (take it off-line) that all my web applications use. I have about 50 web apps running under this website, so I'd like to avoid visiting each of them to change something. I'm thinking I could make a single change in machine.config? Any hints would be appreciated.

+1  A: 

Make all the pages un-available, probably stop the current web site and create an entire new completly blank site in its place. Then put up a custom error page for the 404 (file ot found) error. Custom Errors is a tab on the properties dialog of the web site in IIS. Just create the page you want to send, then change the entry for 404 on the custom errors tab to point to the new file you just created.

pipTheGeek
+9  A: 

If you are using ASP.NET 2.0, you can drop an app_offline.htm page on the root.

More info here.

LordHits
That's cool, I didn't know that. Although our sites at work are a mix of aspx and htm pages so it wouldn't work for us.
pipTheGeek
Nice, I wasn't aware of this either.
Jonathan S.
I found out about app_offline.htm reading Scott Gu's blog, but am surprised I haven't read about it elsewhere. It works as advertised, which helps.
Gordon Bell
A: 

in webconfig

 <rewrite>
        <rules>
            <rule name="redirect all requests" stopProcessing="true">
                <match url="^(.*)$" ignoreCase="false" />
                <conditions logicalGrouping="MatchAll">
                    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" pattern="" ignoreCase="false" />
                </conditions>
                <action type="Rewrite" url="index.php" appendQueryString="true" />
            </rule>
        </rules>
    </rewrite>
se_pavel
A: 

Could you create a new site in IIS with a binding to port 80 with a blank host-header (much like the Default site) and then stop the other site(s)? That way all requests would be handled by the new site, which could simply be a static HTML page notifying users that the site is down for maintenance.

Lazlow
A: 

awesome idea Lazlow works neat :)

Natu