Vulnerability in EPiServer.Forms
I need to store data about expired pages in the DDS. So I don't have to do a search to get them.
How to determine that the page has expired and at the time of expiration to save data in the DDS?
Maybe an event occurs?
Do you want to store more information than is displayed in the Report for expired pages?
I want to store at least the page ID so I can determine what pages expired at any time.
Maybe I don't understand exactly what you want, but if you only want a list of pages that are expired, you can view that report in the "Report viewer" which lists the follwowing for each expired page: Page Name (with a link to the page), Publication Date, Publication Stopped, Last Changed, Changed By, Language, Page Type.
Yes, but can I programmatically obtain a list of these pages?
You can use the API to go through all pages and compare StopPublish date to todays date OR you can run sql cmd netReportExpiredPages (which is the code used by Report center):
public PageReferenceCollection GetPagesExpired(PageReference rootPage, DateTime startDate, DateTime endDate, string publishedByName, ReportDB.SortColumn sortColumn, SortDirection sortDirection, int pageSize, int pageNumber, int langID, out int totalRows)
PageReferenceCollection pageReferences = new PageReferenceCollection();
int resultTotalRows = 0;
IDbCommand dbCommand = this.CreateCommand("netReportExpiredPages");
dbCommand.Parameters.Add(this.CreateParameter("SortDescending", (sortDirection == SortDirection.Descending) ? 1 : 0));
using (IDataReader dataReader = dbCommand.ExecuteReader())
if (resultTotalRows == 0)
resultTotalRows = Convert.ToInt32(dataReader.GetValue(3));
pageReferences.Add(new PageReference(dataReader.GetInt32(0), dataReader.GetInt32(1)));
totalRows = resultTotalRows;
Thank you for the piece of code, but is there an event that is raised when the page has expired?Something like event EventHandler<ContentEventArgs> PublishedContent that occurs when you published the page.
There is as far as I know no specific event. Although it is in fact a PublishedContent event. But I don't think the event is triggered by automatic expiring of pages, but I could be wrong.
If it is, you could check for Published Status of your PageData I guess and do whatever you need to do with it.
There is not a specific event for when a page expires.
Thank you very much for the answers.