When a visitor tries to access a page whos publish date has expired it gets redirected to the login screen.
I would like to redirect the visitor to a 404 page.
Is there a way to fix this? Add a exception handler?
The problem is (as far as I can see), there is no exception when EPiServer sees that the page is not published, just a redirect. The redirect is done inside the PageBase.AccessDenied method, which is virtual, and thus overrideable by you (good news :-) ). However, when invoked, you won't know for what reason it was invoked. You could check the start/stop publish dates and return a 404 status.
I believe you can use the PageData.CheckPublishedStatus(PagePublishedStatus.Published) method for checking this.
/steve
We have solved this problem previously by having a custom login page that checks if the user has come from the edit or admin urls. If not, it redirects to the 404 page (this assumes that the only way they access the login screen is via the edit or admin urls ofcourse)