Parsing error in Umbraco 7 partial view : missing closing brace despite all brace pairs being present
I'm currently working on trying to get to grips with Umbraco and the use of Razor however i'm finding the inline nature of the Razor code particularly difficult. For some reason, when I compile my partial view below (which outputs a Bootstrap carousel to the screen on the page in which it is called) i'm getting the following compilation error:
Line 3: @if (Model.Content.HasValue("bannerImages")){
Parser Error Message: The if block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup.
However I've checked all of my tags in Notepad++ (as this is better at identifying matching tags that Visual Studio) and all of the braces in my document tie up so this leads me to believe that I may be implementing some of the inline Razor code blocks incorrectly. Any ideas?
Sometimes those YSOD's can show messages that are not entirely true...if for instance something should be made to a string or casted to something else.
I'm not that good a razor yet and I feel terified each time I see a ysod that makes no sense to me. But during the past days I've experienced that sometimes it happens if the code is in a "wrong" context or if I forget to add .ToString() to something.
Don't know if you perhaps need to add bannerImagesCollection.ToString() for instance.
After asking the same question on Stack Overflow it would appear that Razor isn't intelligent enough to recognise the shared closing div tag that is used as for either of the cases. I've therefore refactored my code into the following:
Line 19: var cssClass = imageCount < 1 ? "item active" : "item";
Exception Details: System.FormatException: The valueDictionary is not formatted correctly and is missing any of the 'id,nodeId,__NodeId' elements
Is this because Umbraco cannot use the variable I have declared within the partial view?
I believe your problem is the check for imageCount. There are actually two issues the:
1. Inside the code scope you should not use @imageCount, just imageCount
2. In the latest Razor version you can't use split the opening div ike this. You can set the class value in a variable before the opening div tag and then apply it in the opening div tag.
It appears that there is some strange caching going on in Umbraco / Visual Studio. If I go to App_Data/Temp/ExamineIndexes folder and delete all the files from Index folders in there it fixes the issue. Any ideas why this has happened?
I am indeed using the latest version. It's my first time using Umbraco so not aware of any issues in previous versions but this has definitely resolved this issue for me this time around.
Just had this happen - bit of code that had been working fine with media image suddenly threw "The valueDictionary is not formatted correctly and is missing any of the 'id,nodeId,__NodeId' elements" - clearing out the index folders in the App_Data/Temp/ExamineIndexes subfolders sorted it. (Thanks Jason!)
Does anyone have any more information on this error?
I keep receiving it randomly on a production website. The only way to fix it is a combination of deleting the contents of the TEMP folder, republishing the entire site, republishing using /umbraco/dialogs/republish.aspx?xml=true or restarting the app pool.
Also just received this message: two times in the past two days. Never had it before.
I've asked our admin and project manager the following questions:
Were any pushes done today? EDIT: None.
Did the app pool recycle because of high memory? EDIT: No.
What lead up to this? EDIT: Seems to happen randomly. It just happened twice today (on production).
I'll report back when I get the answers above, but please let me know if you think there are more questions that I can ask OR if anyone has a solution that prevents this from happening rather than a solution to resolve it when it happens (such as recycling the app pool)
Parsing error in Umbraco 7 partial view : missing closing brace despite all brace pairs being present
I'm currently working on trying to get to grips with Umbraco and the use of Razor however i'm finding the inline nature of the Razor code particularly difficult. For some reason, when I compile my partial view below (which outputs a Bootstrap carousel to the screen on the page in which it is called) i'm getting the following compilation error:
However I've checked all of my tags in Notepad++ (as this is better at identifying matching tags that Visual Studio) and all of the braces in my document tie up so this leads me to believe that I may be implementing some of the inline Razor code blocks incorrectly. Any ideas?
Hi Jason
Sometimes those YSOD's can show messages that are not entirely true...if for instance something should be made to a string or casted to something else.
I'm not that good a razor yet and I feel terified each time I see a ysod that makes no sense to me. But during the past days I've experienced that sometimes it happens if the code is in a "wrong" context or if I forget to add .ToString() to something.
Don't know if you perhaps need to add bannerImagesCollection.ToString() for instance.
/Jan
After asking the same question on Stack Overflow it would appear that Razor isn't intelligent enough to recognise the shared closing div tag that is used as for either of the cases. I've therefore refactored my code into the following:
However, I'm now getting a valueDictionary error.
Is this because Umbraco cannot use the variable I have declared within the partial view?
Hi Jason,
I believe your problem is the check for imageCount. There are actually two issues the:
1. Inside the code scope you should not use @imageCount, just imageCount
2. In the latest Razor version you can't use split the opening div ike this. You can set the class value in a variable before the opening div tag and then apply it in the opening div tag.
I hope this gets you in the right direction.
/Carsten
Hi Carsten,
This is what I have done in my reply above but I am still getting the dictionary error.
Jason
It appears that there is some strange caching going on in Umbraco / Visual Studio. If I go to App_Data/Temp/ExamineIndexes folder and delete all the files from Index folders in there it fixes the issue. Any ideas why this has happened?
Hi Jason,
My previous reply must have crossed reply, but glad you worked it out on your own.
I have seen a similar issue in the thread http://our.umbraco.org/forum/developers/api-questions/44851-Issue-With-Media-Cache-in-v6
Maybe you're seeing something similar, although on v7? Are you at the latest version (7.1.1.)?
/Carsten
Hi Carsten,
I am indeed using the latest version. It's my first time using Umbraco so not aware of any issues in previous versions but this has definitely resolved this issue for me this time around.
/Jason
Hi Jason,
Have you discovered a solution to your issue? I am encountering something similar with Media/Caching in v7.
Thanks
Just had this happen - bit of code that had been working fine with media image suddenly threw "The valueDictionary is not formatted correctly and is missing any of the 'id,nodeId,__NodeId' elements" - clearing out the index folders in the App_Data/Temp/ExamineIndexes subfolders sorted it. (Thanks Jason!)
I wonder why!?
Does anyone have any more information on this error?
I keep receiving it randomly on a production website. The only way to fix it is a combination of deleting the contents of the TEMP folder, republishing the entire site, republishing using /umbraco/dialogs/republish.aspx?xml=true or restarting the app pool.
I'm seeing this in a production site too. Currently running 6.2.4
Also just received this message: two times in the past two days. Never had it before.
I've asked our admin and project manager the following questions:
Were any pushes done today? EDIT: None.
Did the app pool recycle because of high memory? EDIT: No.
What lead up to this? EDIT: Seems to happen randomly. It just happened twice today (on production).
I'll report back when I get the answers above, but please let me know if you think there are more questions that I can ask OR if anyone has a solution that prevents this from happening rather than a solution to resolve it when it happens (such as recycling the app pool)
I am seeing this in a site and its Umbraco version 7.1.8 assembly: 1.0.5394.16131
Clearing the indexes helped.
Hi,
Did anyone get any further with why this is happening/potential fixes? Seems to happen periodically on a lot of our Umbraco 6.x sites.
Thanks,
Paul
is working on a reply...