Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

send requests to expired content to 404 not login page

Vote:
 

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

#80947
Feb 05, 2014 15:17
Vote:
 

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;
        this.Response.End();
    }

    base.AccessDenied();
}

    

#81002
Feb 06, 2014 17:56
Vote:
 

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?

 

Thanks!

#82096
Mar 05, 2014 13:39
Vote:
 

In case anyone else having this problem finds this thread, here is a blog post offering another solution (putting code in the controller).  http://www.epinova.no/blog/tarjei-olsen/dates/2012/12/handling-page-access-denied-scenarios-in-episerver-cms-7-mvc/

#82097
Mar 05, 2014 13:47
Vote:
 

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

/K

#132652
Aug 14, 2015 17:06
Vote:
 

Hi,

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

Regards
Khurram

#132673
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.