Kentico Kontent .NET Sample Entry Model

What follows is my attempt to define an Entry Model class as described in the blog post to support the Content Type that I described in the blog post at for the Kentico Kontent SaaS headless CMS.

Without the challenges of transforming JSON to HTML as required for Contentful or repeating Field values and Modular Blocks as in Contentstack, my Entry Model for Kentico Kontent feels very simple.

Surprisingly, I get a NullReferenceException accessing the Asset and do not really feel like taking the time to investigate.

Potentially excluding access to Assets and Entries (Items) referenced by Entries (Items) of this Content Type, this Entry (Item) Model class could work with CMS from other vendors.

5 thoughts on “Kentico Kontent .NET Sample Entry Model

  1. Hi John,
    the Asset element is, in fact, a collection of assets. Therefore, you need to use an IEnumerable in the model (and FirstOrDefault() when you try to render it). I tested the adjusted code and it works fine.

    For developers’ convenience, we offer a tool that generates the models based on the content types in Kontent automatically – feel free to give it a try

    I also noticed that you’re using a beta NuGet package. In that case, you might also need to change Asset to IAsset but otherwise, it should work well too.
    Please let us know in the GitHub issues ( if you notice any problems. We’ll be releasing a new major version in a couple of weeks.



  2. Thanks Petr! Sorry, I really don’t have time to dig very deep on these. If you want to have someone create an test an updated pastebin, I will change from my link to yours and update the text.

    I haven’t tried your model generator. Does it do much beyond create classes with flat lists of simple properties? Does it do something to expose all of the referenced item? Can it pull that data from cached JSON representations of the referenced items, or does it have to pull each item individually, or does it inline/build out the Item reference structure (to some level of depth) before serialization through the RESTful API?

    If you could provide a links about any one or more of any of these topics with your headless system, I would be glad to link to them. I’m really here to promote .NET Core and let the customers choose the vendor, which seems to have almost nothing to do with .NET anyway.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: