
Editorial illustration.
Originally published 16 June 2023; rewritten and reviewed on 15 October 2026.
I followed the Kentico Web API integration steps line by line and still hit a startup exception instead of a working endpoint. Nothing in the controller or route registration looked wrong. The real culprit was sitting in bin/: the separate Web API project I had wired up was referencing newer Kentico.Libraries NuGet packages than the actual CMS instance it was supposed to talk to.
When you are working on a legacy or enterprise Kentico site—the kind where the main CMSApp project has been running in production for years—NuGet defaults will happily pull the latest minor or hotfix release if you do not pin the version explicitly. On .NET Framework, a Could not load file or assembly or MissingMethodException at startup rarely tells you that your two projects simply drifted apart by one hotfix.
Compare the installed assemblies before touching the routes
A shared namespace does not guarantee binary compatibility. Whenever an external ASP.NET Web API project fails to boot against Kentico, the fastest diagnostic step is to check the exact file versions deployed in both bin/ folders, not just what Visual Studio’s NuGet UI claims is installed.
In PowerShell, you can inspect the deployed CMS assemblies directly on the server or in your build output:
Get-Item .\CMS\bin\CMS.*.dll |
Select-Object Name, @{N='FileVersion';E={$_.VersionInfo.FileVersion}} |
Sort-Object Name
Compare that output against .\CustomApi\bin\CMS.*.dll and check packages.config (or <PackageReference> if you are on SDK-style projects). Pay attention to the fourth segment of the version number—Kentico hotfixes often bump assembly file versions and introduce subtle signature changes in CMS.DataEngine or CMS.DocumentEngine even within the same major release.
Back when I first wrote this note, I had linked guides spanning Kentico 8.1, 8.2, 9, 10, 11, 12, and 13. Those versions look similar on paper, especially around CMSContext and DocumentHelper, but their initialization hooks (CMSApplication.Init() vs. CMS.DataEngine.CMSApplication.PreInit()) and Web API routing conventions are not interchangeable. Reading a Kentico 12 blog post while debugging a Kentico 11 codebase is an easy way to lose an afternoon.
Pin the API to the CMS, not the other way around
Once you spot the mismatch, you have two choices: upgrade the CMS to match the new API packages, or downgrade the API’s Kentico.Libraries reference to match the running CMS.
In almost every maintenance project, aligning the API project to the existing CMS is the safer call. Upgrading a live Kentico instance just to satisfy a single new endpoint drags in database schema updates, Web.config bindingRedirect changes, and regression testing across forms, scheduled tasks, and custom modules that were already stable.
If you do pin the older package, document the exact version and hotfix number right inside the project README or .csproj comment so the next developer does not run Update-Package out of habit. Also inspect Web.config for stale <dependentAssembly> redirects—an old bindingRedirect pointing Newtonsoft.Json or CMS.Core to the wrong version can mask a clean package downgrade.
Treat the Web API as a separate security boundary
Getting CMSApplication.Init() to succeed without throwing is only half the job. An ASP.NET Web API project that references Kentico.Libraries has direct access to InfoProvider classes and database connections, which means it bypasses the CMS’s page-level ACLs unless you enforce them yourself.
Before exposing any custom endpoint:
- Enforce authentication and role checks explicitly with
[Authorize]or a customAuthorizeAttributethat validates the caller’s token or CMS membership, rather than assuming IIS or the front-end portal handles it. - Map to explicit DTOs instead of returning
TreeNodeorUserInfoobjects directly. Serializing raw Kentico info objects leaks internal columns, GUIDs, and sometimes password hashes or metadata you never intended to expose. - Return structured errors without stack traces in production (
customErrors/IncludeErrorDetailPolicy.Never) so a bad query parameter does not reveal your connection string or assembly layout.
The habit that stuck with me from this bug is straightforward: when integration code follows the docs to the letter and still fails at boot, stop rewriting the controller and audit the dependency contract between the two projects first.
Related reading
Images from the original article
The following images are retained as historical context; interfaces and configuration options may have changed.



