Kentico UserInfoProvider not working as expected in a console app

前端 未结 3 1739
花落未央
花落未央 2021-01-28 09:24

This code works fine within a Kentico website:

var users = UserInfoProvider.GetUsers();
for (int x = 0; x < users.Count(); x++
{
    UserInfo currentUser = us         


        
3条回答
  •  日久生厌
    2021-01-28 10:01

    Before you start working with Kentico CMS API from an external application make sure you call the following lines:

    CMS.DataEngine.ConnectionHelper.ConnectionString = "your connection string";
    CMS.Base.SystemContext.WebApplicationPhysicalPath = Application.StartupPath;
    CMS.DataEngine.CMSApplication.Init();
    

    Then, you'll be also able to use UserInfoProvider.GetUsers() object query instead of using DataQuery.Execute().

提交回复
热议问题