You are not using ASP.NET Core or Kentico Xperience's API correctly. The
Configure method (which I touch on in my blog post Kentico Xperience Design Patterns: Good Startup.cs Hygiene ) is used for defining the middleware pipeline that ASP.NET Core uses to process a request.
There are no guarantees about a request being processed at that point in the application (the pipeline needs to be defined before any requests can be handled).
Kentico Xperience requires an active request to populate
SiteContext because it uses the request's URL to identify the request's associated site. Without an active request, there's no value populating
You should either be using ASP.NET Core middleware or an MVC Controller to process a request.
Also, you shouldn't use static global context objects like
SiteContext in ASP.NET Core. Instead use dependency injection and access the current site through