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
Look at Johans answer in this thread:
But change to use IContentLoader instead of DataFactory
I even commented on that thread also :)
You are everywhere!;-)
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
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)..
Thanks, i'll look in to this as a possible direction. -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 (PageContext.Page.StopPublish <= DateTime.Now)
filterContext.Result = new HttpStatusCodeResult(404, "Not found");
Hope this helps!
This is literally exactly what I needed. Thanks!
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.