Inaactive Pages

Vote:
 

Hi,

I'm looking into an issue we're having with Episerver. I'd like the ability to take web pages in Episerver that have been published, and disable it so if a customer browses to this page, they'll receive a 404 error. If I expire this page, or I change the rights to this page to only have administrators and browse to the page, than we don't get a 404 page, we get an Episerver log in prompt. Is there any way to like archive a page, or set a page as inactive?

Help with this would be greatly appreciated.

-Paul

#140651
Oct 26, 2015 19:58
Vote:
 
#140659
Edited, Oct 26, 2015 20:48
Vote:
 

I even commented on that thread also :)

#140660
Oct 26, 2015 20:57
Vote:
 

You are everywhere!;-)

#140662
Oct 26, 2015 21:13
Vote:
 

I had seen this link before but wanted to reach out to you guys to see if there was anything less kludge. Seems like this is the only answer, which I find odd because you’d think that disabling a page that has already been published would be very basic functionality and shouldn’t require us to expire it / write code to override the default behavior. Is this a request we can put in for the next version?

Anyway, I did want to thank you guys the quick response. I did try to go ahead and implement your method however, one issue I’m running in to is that we are using Episerver 8 with MVC, and our page types don’t inherit from PageBase. They do inherit from SitePageData and maybe I’m missing something, but I don’t see any methods in this class, or any classes that this enherits from called AccessDenied.

-Paul

#140665
Oct 26, 2015 21:33
Vote:
 

While running on Mvc, I would look for ActionFilters and execute code fragment mentioned above before action executing event to catch and inspect requested page, and if needed redirect to 404 or something. Just remember - it's wise to do so only in "visitor mode" -> when somebody is browsing you site. Probably editors will still need to access that page, even it's "inactive". You can check this using PageEditing.IsInEditMode or similar (writting from top of my head)..

#140666
Oct 26, 2015 21:45
Vote:
 

Thanks, i'll look in to this as a possible direction. 

-Paul

#140667
Oct 26, 2015 21:53
Vote:
 

Hi Paul,

You can create an action filter as Valdis suggested, or override OnAuthorization method in your base controller:

protected override void OnAuthorization(AuthorizationContext filterContext)
{
    // don't throw 404 in edit mode
    if (!PageEditing.PageIsInEditMode)
    {
        if (PageContext.Page.StopPublish <= DateTime.Now)
        {
            filterContext.Result = new HttpStatusCodeResult(404, "Not found");
            return;
        }
    }

    base.OnAuthorization(filterContext);
}

Hope this helps!

#140679
Oct 27, 2015 12:04
Vote:
 

This is literally exactly what I needed. Thanks!

#140683
Oct 27, 2015 14:19
Vote:
 

For future reference, Dejan has blogged about it here: http://www.dcaric.com/blog/episerver-how-to-return-404-for-expired-pages

Several solutions for different scenarios.

#140746
Edited, Oct 29, 2015 8:48
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.