Umbraco.Field returns Input string was not in a correct format. after upgrade from 7.2 to 7.7
Hi,
I've just updated a Umbraco 7.2 website (to fix a problem with content not being displayed when clicking on nodes in the backend) to 7.7. However when I try to access the site, some of my Razer code for displaying properties i.e
@Umbraco.Field("boothHireBodyText")
Now returns a runtime error "Input string was not in a correct format.". This worked without issue in 7.2 so what has changed to stop this from working now and does anyone know how to resolve the issue?
I've checked the properties and they are correctly populated so I am at a loss as to why this is all suddenly broken.
<div id="booth-info-area">
<div class="content-wrapper">
<div class="half-width-column left-column">
<h1>@Umbraco.Field("boothHireTitle")</h1>
@Model.Content.GetPropertyValue("boothHireBodyText")
<a class="button" href='@Umbraco.NiceUrl(Int32.Parse(Umbraco.Field("findOutMore").ToString())).ToString()'>FIND OUT MORE & BOOK NOW</a>
</div>
<div class="half-width-column right-column">
<img src="@Umbraco.Media((int)@CurrentPage.boothHireImage).Url.ToString()" alt="booth">
</div>
</div>
The strange thing is that it is working for some properties and not others. Checking in the content everything looks fine. I think the upgrade has broken something fundamental.
I've tried using @Model.Content.GetPropertyValue("boothHireBodyText") instead but it causes exactly the same issue.
The first value works just fine, the second one throws this error. I wonder if it's being caused by the actual content, but it's just test in the rich text editor so I can't see why...?
Unfortunately it causes exactly the same problem. I've also tried deleting and recreating the property, the problem persists.
I have to say we've not had a good experience with Umbraco over the past few years, we've had several sites that break on older versions, but when we upgrade we seem to hit difficult and time consuming issues. This has forced us to migrate back to Wordpress as upgrades seem to be much more straightforward and support is easier. This is a shame because I fundamentally like Umbraco.
Thanks for you help anyway, maybe I'll find a solution sometime.
So I've debugged in by grabbing the Model.Content as an IPublishedProperty interface. If I browse the properties in the debugger, everything is present and correct.
I can use the following code to get the property:
@{
IPublishedContent Content = Model.Content;
string Test = Content.GetPropertyValue("boothHireBodyText").ToString();
}
@{
string Test = Model.Content.GetPropertyValue("boothHireBodyText").ToString();
}
It works too, so it's as if the Razer parser isn't always working correctly.
More investigating reveals that exactly the same line of code accessing the same property works on some parts of the same page but not others. I've never seen anything like this before.
I've finally fixed it. After cleaning up absolutely everything I managed to get an upgrade to work properly. There must have been some locked files or a copying error I guess I ended up with an incomplete installation.
Thanks for the help Alex - I got there in the end, but it has been a frustrating 6 hours!
Umbraco.Field returns Input string was not in a correct format. after upgrade from 7.2 to 7.7
Hi,
I've just updated a Umbraco 7.2 website (to fix a problem with content not being displayed when clicking on nodes in the backend) to 7.7. However when I try to access the site, some of my Razer code for displaying properties i.e
@Umbraco.Field("boothHireBodyText")
Now returns a runtime error "Input string was not in a correct format.". This worked without issue in 7.2 so what has changed to stop this from working now and does anyone know how to resolve the issue?
I've checked the properties and they are correctly populated so I am at a loss as to why this is all suddenly broken.
Any help greatly appreciated,
Many thanks,
Damien
Hi Damien
Just checked in 7.7, @Umbraco.Field("boothHireBodyText") - works fine for me.
Can you show all the code? Maybe the error in some other place.
Thanks,
Alex
Hi Alex, the code is very simple:
The strange thing is that it is working for some properties and not others. Checking in the content everything looks fine. I think the upgrade has broken something fundamental.
I've tried using @Model.Content.GetPropertyValue("boothHireBodyText") instead but it causes exactly the same issue.
The following code:
The first value works just fine, the second one throws this error. I wonder if it's being caused by the actual content, but it's just test in the rich text editor so I can't see why...?
By the way, what if we look at value of this property? What are you storing there?
Try to wrap method like that:
Unfortunately it causes exactly the same problem. I've also tried deleting and recreating the property, the problem persists.
I have to say we've not had a good experience with Umbraco over the past few years, we've had several sites that break on older versions, but when we upgrade we seem to hit difficult and time consuming issues. This has forced us to migrate back to Wordpress as upgrades seem to be much more straightforward and support is easier. This is a shame because I fundamentally like Umbraco.
Thanks for you help anyway, maybe I'll find a solution sometime.
Are you using ModelsBuilder? Is it enabled?
I'm not sure, this is a new feature. Does it need to be enabled?
it's better to disable it just after upgrade
Hi Alex, just checked the web.config and it is disabled.
Looking at the exception in more detail, the error is as follows:
" at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)\r\n at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)\r\n at ASP.PageViewsHomecshtml.Execute() in d:\GetYourBoothOn\GetYourBoothOn\Views\Home.cshtml:line 40"
This just doesn't seem to make any sense. Why is it even calling Number.StringToNumber? I've tried deleting and recreating the property, same issue.
I've tried reverting back and reinstalling the upgrade, same problem. Something is very broken in this installation.
So I've debugged in by grabbing the Model.Content as an IPublishedProperty interface. If I browse the properties in the debugger, everything is present and correct.
I can use the following code to get the property:
However the equivalent:
Throws the error. This is very strange.
If I enclose it in Razer tags i.e.
It works too, so it's as if the Razer parser isn't always working correctly.
More investigating reveals that exactly the same line of code accessing the same property works on some parts of the same page but not others. I've never seen anything like this before.
I've finally fixed it. After cleaning up absolutely everything I managed to get an upgrade to work properly. There must have been some locked files or a copying error I guess I ended up with an incomplete installation.
Thanks for the help Alex - I got there in the end, but it has been a frustrating 6 hours!
I'm really glad that you solved the issue!!! :)
Have a good beer after work today :)
is working on a reply...