I was getting CmsServerException (Microsoft.ContentManagement.Publishing.CmsServerException) saying “ Server error. Contact the site administrator. ”. when trying to call CmsHttpContext.Current.Searches.GetByGuid method.
It was hard to find out why this exception occurs, because there was no detail included.
Anyway I found out why;
I was calling the GetByGuid method like:
CmsHttpContext.Current.Searches.GetByGuid(myGuid.ToString());
Which was wrong…
When you make ToString() to a Guid, it does not return paranthesis of guid in the return string. On the other hand, GetByGuid wants its parameter string to have paranthesis.
It should be like:
CmsHttpContext.Current.Searches.GetByGuid(myGuid.ToString(“B”));
So that when you send the guid properly, you will get rid of CMSServerError..