Vulnerability in EPiServer.Forms

Try our conversational search powered by Generative AI!

Expired page event



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?

Jan 04, 2016 12:29

Do you want to store more information than is displayed in the Report for expired pages?

Jan 04, 2016 12:45

I want to store at least the page ID so I can determine what pages expired at any time.

Jan 04, 2016 14:11

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.

Jan 04, 2016 14:55

Yes, but can I programmatically obtain a list of these pages?

Edited, Jan 04, 2016 15:08

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("PageID", rootPage.ID));
		dbCommand.Parameters.Add(this.CreateDateParameter("StartDate", startDate));
		dbCommand.Parameters.Add(this.CreateDateParameter("StopDate", endDate));
		dbCommand.Parameters.Add(this.CreateParameter("Language", langID));
		dbCommand.Parameters.Add(this.CreateParameter("PublishedByName", publishedByName));
		dbCommand.Parameters.Add(this.CreateParameter("PageSize", pageSize));
		dbCommand.Parameters.Add(this.CreateParameter("PageNumber", pageNumber));
		dbCommand.Parameters.Add(this.CreateParameter("SortColumn", sortColumn.ToString()));
		dbCommand.Parameters.Add(this.CreateParameter("SortDescending", (sortDirection == SortDirection.Descending) ? 1 : 0));
		using (IDataReader dataReader = dbCommand.ExecuteReader())
			while (dataReader.Read())
				if (resultTotalRows == 0)
					resultTotalRows = Convert.ToInt32(dataReader.GetValue(3));
				if (dataReader.IsDBNull(1))
					pageReferences.Add(new PageReference(dataReader.GetInt32(0)));
					pageReferences.Add(new PageReference(dataReader.GetInt32(0), dataReader.GetInt32(1)));
	totalRows = resultTotalRows;
	return pageReferences;


Jan 04, 2016 15:17

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.

Jan 04, 2016 16:11

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.

Jan 04, 2016 16:41

There is not a specific event for when a page expires.

Jan 05, 2016 8:34

Thank you very much for the answers.

Edited, Jan 05, 2016 8:46
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* 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.