Tales from the Evil Empire

Bertrand Le Roy's blog

News


Bertrand Le Roy

BoudinFatal's Gamercard

Tales from the Evil Empire - Blogged

Blogs I read

My other stuff

Archives

Taking an Orchard site offline while you update it

(c) Bertrand Le Roy 2012If your hosted environment does not give you a staging site and the means to swap it easily with the production environment like Azure Cloud Services do, or if you don’t have a staging database, or if you just need to take your site offline for the public while you perform data updates in the admin, you may be wondering what solutions you have, if any.

IIS has an app_offline.htm feature that you can use, that will serve a static page for all requests but that’s rather brutal as it does not just take the site offline for your users, it also does so for you. While that file exists, you can do absolutely nothing with your site. You cannot access the admin, you cannot preview your changes, nothing. So when you flip the switch back, it’s anyone’s guess whether the changes you blindly made actually work, even if they did on your machine…

We need a better solution. Well, I happen to have one...

All you have to do is create a new theme named “Offline” with just one /Views/Layout.cshtml file containing a message along the lines of “We are updating the site. We apologize for the inconvenience. Please come back in a few minutes.” You can add stylesheets to make it pretty if you want to. It’s a full theme, you can go crazy.

The important thing is that this theme has one layout, and that this layout does nothing but display its message. It has no zones, so no dynamic content is going to be served to the public from the site no matter what URL is hit.

Once you have made this theme current, all your visitors are seeing it, but you can still access the admin of the site and do whatever you want.

Better, you can use the “Theme Preview” feature of Orchard to check what your changes look like while your users continue to see the “offline” page. Just go to Themes, and click Preview on your regular theme…

Once you are satisfied with your changes and judge the site to be ready to be taken back online, just restore your theme as the current. The “Offline” theme can sit there and do nothing until the next time you need it.

I’ve used this technique successfully last time I updated an Orchard site. It worked great. I hope it helps others…

Comments

Philip Senechal said:

Holy crap, that's brilliant! I've been using the app_offline.htm method and it's a royal PITA. This is such an easy alternative and so much more functional. Thanks!

# March 12, 2013 3:19 PM

Kees Schouten (Znowman) said:

Great idea. Thanks!

# March 12, 2013 5:07 PM

Robert said:

The breadth of your knowledge (and other's) about Orchard needs to be memorialized in a book.

# March 13, 2013 12:50 PM

Rafael said:

Bertrand, this is a great idea! Thanks for sharing! I have a quick Orchard question. What is your recommendation if I have to create a sub menu that opens a file on a new window? I created a Content Menu (ie: File) and a Custom Link Menu (ie: Open) under it, but it will always open it on the current window. I have checked a few modules such as "Target: blank" and "Hyperlink Custom Field" but they didn't work well for me. Thanks in advance.

# March 13, 2013 2:39 PM

Bertrand Le Roy said:

Rafael: this is off-topic and would be better asked on on the discussions forum on CodePlex. I think you should write a custom menu item type. It's fairly easy.

# March 13, 2013 2:47 PM

Roland said:

Genius, and so simple too...

# March 14, 2013 9:16 AM