There are many times when you need to figure out if an Episerver page is published, or not, with the two most common scenarios being multi-language pickers and SEO alternative URL listing.  

In this tutorial, you will find out how you can use the IPublishedStateAssessor to achieve this.

The IPublishedStateAssessor API

As the name implies, the IPublishedStateAssessor can be used to figure out a page PublishedState. To use the API, you can simply inject it in, like you would any other Episerver API.  I recommend that you use constructor injection, as the ServiceLocator is an anti-pattern, however, to make this demo simple to understand, I'm using it.

Using this API will ensure that the pages have been published and that it hasn't expired. You pass in the 'IContent' and you get a yes/no back. Simple!