1

How do you put web services into maintenance mode?

I've tried the app_offline.htm, doesn't seem to work well for web services. Does work for web site though.

app_offline.htm worked fine for web sites, but not for web service. When I called an web service function via code that's supposedly under maintenance (put the app_offline.htm under the root directory of the IIS web service), I still got the proper response as usual.

Ideally I would like the web service that's under maintenance to return to me a message like "under maintenance".

Trinimon
  • 13,839
  • 9
  • 44
  • 60
sakraycore
  • 13
  • 1
  • 3

2 Answers2

1

You can edit your Global.asax as suggested by this answer to another question. Then trigger it by setting a flag when you are in maintenance mode

In my opinion, when a service is unavailable, you should respond with a 503 Service Unavailable status; but you can do anything you like with the response.

Community
  • 1
  • 1
Colin Pickard
  • 45,724
  • 13
  • 98
  • 148
0

Create a utility function for your web services, which checks for the presence of app_offline.htm at your website's root path, and responds accordingly.

Note that if you wanted to get fancy with it, you could use a part of the WCF pipeline (assuming you're using WCF and not the legacy .ASMX services) to modify your services/methods by using an attribute (eg, this method).

Community
  • 1
  • 1
McGarnagle
  • 101,349
  • 31
  • 229
  • 260