Try our conversational search powered by Generative AI!

send requests to expired content to 404 not login page


currently in our 7.5 project any request to a page that has been set to expired will be sent the login page. this is not great behaviour for a production system where by anyone with a bookmark etc to the expired content will get visibility to our login box.

how can we make sure these requests are sent to the 404 page. we are using mvc

Feb 05, 2014 15:17

You can override the AccessDenied() method in the template. This is preferably done in a base class.


public override void AccessDenied()
    // Important! Do not access CurrentPage directly with an anonymous user, this will cause a loop
    var currentPage = DataFactory.Instance.GetPage(this.CurrentPageLink);

    if (!PageEditing.PageIsInEditMode
        && (!currentPage.CheckPublishedStatus(PagePublishedStatus.Published) || currentPage.IsDeleted))
        this.Response.Status = "404 Not Found";
        this.Response.StatusCode = 404;



Feb 06, 2014 17:56

Hi Johan,


I'm having the same issue in EPiServer CMS 7.1.  Can I trouble you to elaborate on your answer.  Which class has the AccessDenied method?



Mar 05, 2014 13:39

In case anyone else having this problem finds this thread, here is a blog post offering another solution (putting code in the controller).

Mar 05, 2014 13:47

This bug have been fixed in latest versions (probably in 7.19)


Aug 14, 2015 17:06


I was facing this issue for disabled products (EPiserver Commerce) and those were fixed as private bugs

Bug #116989: Inconsistent behavior with unpublished content

Bug #117312: Inconsistent routing to unpublished content in MVC and web forms


Aug 17, 2015 10:40
* 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.