+1-888-365-2779
Try Now
More in this section

Forums / Deployment / how do you take a site offline?

how do you take a site offline?

8 posts, 0 answered
  1. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    23 Sep 2008
    Link to this post
    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!
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    24 Sep 2008
    Link to this post
    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.
  3. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    13 Oct 2008
    Link to this post
    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!
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    15 Oct 2008
    Link to this post
    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.
  5. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    15 Oct 2008
    Link to this post
    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?
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    20 Oct 2008
    Link to this post
    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.
  7. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    20 Oct 2008
    Link to this post
    thats about what I figured but I never would have thought to do it in post authentication. many thanks, this looks perfect :)
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    21 Oct 2008
    Link to this post
    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.
Register for webinar
8 posts, 0 answered