Website channel with ID 0 does not exist
My site runs fine locally, however once deployed to azure, I get the error "Website channel with ID 0 does not exist" at points where I am trying to get the webSiteChannelContext. The site loads fine in the CMS, I can edit the pages without problem. However, on the live site I get an error page due to the above issue with the site context.
What could cause this?
Environment
Xperience by Kentico version: [30.3.1]
.NET version: [8]
Execution environment: [azure)]
Link to relevant Xperience by Kentico documentation
Answers
The website channel domain needed to be changed from localhost to the azure url
It's also worth noting that code executing within the administration UI outside of the Page Builder is not associated with a website, even if you access the administration UI through the same domain as one of your website channels.
Within the admin UI (outside of the Page Builder) the website channel context ID will be 0.
I had this issue with another deployment in azure and would only get 500 server error. I was unable to update the domain from the admin UI. I was able to update the domain instead through the sql query editor in azure, stop then start the site. After this the site loaded without issue.
I would recommend specifying the domain through app settings which would be customized for each environment you are deploying to instead of doing a deployment and then updating the domain to match through the admin UI.
This is how we apply this configuration in Xperience by Kentico SaaS where the domain settings for each SaaS environment are all defined in the Xperience Portal, not through the Xperience application.
You shouldn't ever need to do any of this through the database.
To answer this question, you have to login first.