Telerik

Forums

Skip Navigation LinksHome > Web Content Management > Developer Network / Forums / Sitefinity 3.x: Deployment > how do you take a site offline?

Not answered how do you take a site offline?

Feed from this thread
  • SelArom MVP SelArom's avatar

    Posted on Sep 23, 2008 (permalink)

    I'm wondering how to disable a site so that it can be in a "maintenance mode" while changes are made, such as installing hotfixes or updating user controls without creating problems on the site.

    I tried setting disabled to true in web.config for the cms entry but that tried to install the whole thing again!

    Reply

  • Telerik Admin admin's avatar

    Posted on Sep 24, 2008 (permalink)

    Hi SelArom,

    You can add a file in the application root named App_Offline.htm. Then, IIS will automatically rewrite all requested URLs to this file. Deleting App_Offline.htm will bring the web application back.

    Hope this helps.

    All the best,
    Ivan Dimitrov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.

    Reply

  • SelArom MVP SelArom's avatar

    Posted on Oct 13, 2008 (permalink)

    is it possible to have the site just disabled for external (non-admin) users? that way I can make changes to the site and test it while its down but no one else can use it.

    thanks!

    Reply

  • Telerik Admin admin's avatar

    Posted on Oct 15, 2008 (permalink)

    Hello SelArom,

    There is a way to do this using a custom http module. In App_Code create a class called OffHttpModule that inherits IHttpModule.

    public class OffHttpModule : IHttpModule 
        #region IHttpModule Members 
     
        public void Dispose() 
        { 
        } 
     
        public void Init(HttpApplication context) 
        { 
            context.BeginRequest += new EventHandler(context_BeginRequest); 
        } 
     
        void context_BeginRequest(object sender, EventArgs e) 
        { 
            string offlinePath = String.Concat(UrlHelper.LowerApplicationPath, "offline.aspx"); 
            HttpContext context = HttpContext.Current; 
            string path = context.Request.RawUrl; 
            //here we check wether the requested url points to the admin part of Sitefinity or not 
            //and make a redirection to the offline page. 
            if (!path.Equals(offlinePath) 
                && CmsUrlContext.Current != null 
                && context.Items[UrlHelper.EditModeKey] == null
                context.Response.Redirect(offlinePath, true); 
        } 
        #endregion 

    Then, open your web.config file and register the new handler as the code below demonstrates.

    <httpModules> 
          <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 
          <add name="Cms" type="Telerik.Cms.Web.CmsHttpModule, Telerik.Cms" /> 
          <add name="Offline" type="OffHttpModule, App_Code" /> 
          <add name="RadUploadModule" type="Telerik.Web.UI.RadUploadHttpModule, Telerik.Web.UI" /> 
        </httpModules> 

    By doing so, you will be able to manage your application and see the pages in edit and preview modes. Meantime, all public requests will be redirected to "offline.aspx"

    I hope this helps.

    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.

    Reply

  • SelArom MVP SelArom's avatar

    Posted on Oct 15, 2008 (permalink)

    interesting, thanks for the reply. I actually acheived the same functionality by setting permissions for Everyone to Deny cms access, and handled the permissions exception by forwarding them to an offline page. works pretty well,

    but what I want to do is enable the LIVE public end site to only administrators, where the public (not logged in) users would see an offline message. I'm guessing that I could take the same approach as your handler, but instead use a check to see if the user is logged in, does that sound right?

    Reply

  • Telerik Admin admin's avatar

    Posted on Oct 20, 2008 (permalink)

    Hi SelArom,

    It the example below all logged users will be able to see the public part of Sitefinity without problems. Users that have not been authenticated through Sitefinity login, will be redirected to our offline page.

    public class OffHttpModule : IHttpModule 

        #region IHttpModule Members 
     
        public void Dispose() 
        { 
        } 
     
        public void Init(HttpApplication context) 
        { 
            context.PostAuthenticateRequest += new EventHandler(context_PostAuthenticateRequest); 
        } 
     
        void context_PostAuthenticateRequest(object sender, EventArgs e) 
        { 
            string offlinePath = String.Concat(UrlHelper.LowerApplicationPath, "offline.aspx");  
            HttpContext context = HttpContext.Current; 
            string path = context.Request.RawUrl; 
            if (!path.Equals(offlinePath) 
                && CmsUrlContext.Current != null 
                && context.Items[UrlHelper.EditModeKey] == null 
                && !((context.User != null
                    && context.User.Identity.IsAuthenticated 
                    && (context.User is RolePrincipal) 
                    && ((RolePrincipal)context.User).ProviderName.Equals(UserManager.Default.RoleProvider.Name))) 
            { 
                context.Response.Redirect(offlinePath, true); 
            } 
        } 

        #endregion 

    I hope this helps.


    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.

    Reply

  • SelArom MVP SelArom's avatar

    Posted on Oct 20, 2008 (permalink)

    thats about what I figured but I never would have thought to do it in post authentication. many thanks, this looks perfect :)

    Reply

  • Telerik Admin admin's avatar

    Posted on Oct 21, 2008 (permalink)

    Hi SelArom,

    I am glad to hear that this helps you. Le t us know if there is anything else that we can do for you.

    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.

    Reply

Back to Top

Skip Navigation LinksHome > Web Content Management > Developer Network / Forums / Sitefinity 3.x: Deployment > how do you take a site offline?

Powered by Sitefinity ASP.NET CMS

Contact Us | Site Feedback | Terms of Use | Privacy Policy
Copyright © 2002-2010 Telerik. All rights reserved.