Error in General Page Properties after setting Document rating via API

Matt Fox asked on October 25, 2016 19:51

After setting a rating on a document via the API (TreeProvider.AddRating), viewing the General Properties tab produces an error:

Message: Exception of type 'System.Web.HttpUnhandledException' was thrown.

Exception type: System.Web.HttpUnhandledException
Stack Trace: 
at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at ASP.cmsmodules_content_cmsdesk_properties_general_aspx.ProcessRequest(HttpContext context) in c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\6f7b9a8f\5407338a\App_Web_general.aspx.5a27d124.3u41e9qi.0.cs:line 0
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Message: CurrentRating must be greater than MaxRating
Parameter name: CurrentRating

Exception type: System.ArgumentOutOfRangeException
Stack Trace: 
at AjaxControlToolkit.Rating.set_CurrentRating(Int32 value)
at CMSAdminControls_ContentRating_Controls_Stars.ReloadData()
at System.Web.UI.Control.OnLoad(EventArgs e)
at CMS.ExtendedControls.AbstractUserControl.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

After searching, it looks as if the control needs to set the MaxRating property before the CurrentRating, but it is not. Would this be a bug, or are we not following the proper procedure to update a document rating?

Recent Answers


Joshua Adams answered on October 25, 2016 20:50

Have you tried using the content rating webpart? Does that throw the error too? It may help to use that as a reference for your code, so you can see if you are missing something or not setting it right.

https://docs.kentico.com/display/K8/Using+the+Content+rating+web+part

1 votesVote for this answer Mark as a Correct answer

Richard Sustek answered on October 26, 2016 09:58

You should be able to set the rating using e.g. this way(thats how we do it internally):

float currentRating = 0.5; // has to be within 0-1 range
bool checkUserRated = true;
TreeProvider.AddRating(DocumentContext.CurrentDocument, currentRating , checkUserRated );
1 votesVote for this answer Mark as a Correct answer

Matt Fox answered on October 26, 2016 14:31

Richard:

We're doing that on our front-end (an MVC app), but it's when we view the document in the backend CMS that we're getting the error. This leads us to wonder if we're doing something wrong.

Does anyone know if there's a way to set the MaxRating property? The error seems to suggest that it needs set first.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.