Bug reports Found a bug? Post it here please.
Version 6.x > Bug reports > Error with CMSContext.GetDocumentUrl View modes: 
User avatar
Member
Member
spectro-jarlen - 12/3/2011 7:16:32 PM
   
Error with CMSContext.GetDocumentUrl
Hi there,

I've been getting errors on my site in the event log that has to do with CMSContext.GetDocumentURL.

My code is:

string _url = string.Empty;
_url = CMSContext.GetDocumentUrl(CMSContext.CurrentDocument.DocumentID).ToString();



The error is:

EventID: 10562
EventType: E
EventTime: 12/3/2011 5:14:13 PM
Source: MacroResolver
EventCode: RESOLVEDATAMACRO
IPAddress: 205.250.144.243

EventDescription: Error while evaluating expression: CMSContext.GetDocumentUrl(CMSContext.CurrentDocument.DocumentID)|(user)username|(hash)encryptedhashcode

[MacroExpression.Evaluate]: Method GetDocumentUrl has invalid number of arguments.
EventUrl: /Collection/Collection---Jewellery-Lines-(1)/Fine-Art/Kerala-s-Edge----Gayatri-Sunrise.aspx
EventMachineName: P3NW8SHG223
EventUserAgent: Mozilla/5.0 (iPad; CPU OS 5_0_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A405 Safari/7534.48.3


Has anyone every come across this, and is there a workaround? Visual Studio says the code is correct and doesn't give me any errors, so maybe it's an issue in v6 of Kentico? Am I using a deprecated function or something?

thanks,
Jarlen

User avatar
Kentico Support
Kentico Support
kentico_janh - 12/4/2011 4:11:14 AM
   
RE:Error with CMSContext.GetDocumentUrl
Hello Jarlen,

This is strange. I have tried the same piece of code as you have in my webpart and I always saw the right URL without any error. May I ask you, where do you use this code you mentioned? Could you please also create a new webpart with one Label and try to run it only with the source code you wrote to me?

protected void Page_Load(object sender, EventArgs e)
{
string _url = string.Empty;
_url = CMSContext.GetDocumentUrl(CMSContext.CurrentDocument.DocumentID).ToString();

Label1.Text = _url;
}


Best regards,
Jan Hermann