Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Damien Green 72 posts 134 karma points
    Dec 15, 2017 @ 11:11
    Damien Green
    0

    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

  • Alex Skrypnyk 6132 posts 23951 karma points MVP 7x admin c-trib
    Dec 15, 2017 @ 11:13
    Alex Skrypnyk
    0

    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

  • Damien Green 72 posts 134 karma points
    Dec 15, 2017 @ 11:28
    Damien Green
    0

    Hi Alex, the code is very simple:

    <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 following code:

    @Model.Content.GetPropertyValue("boothHireTitle")
    @Model.Content.GetPropertyValue("boothHireBodyText")
    

    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...?

  • Alex Skrypnyk 6132 posts 23951 karma points MVP 7x admin c-trib
    Dec 15, 2017 @ 11:51
    Alex Skrypnyk
    0

    By the way, what if we look at value of this property? What are you storing there?

  • Alex Skrypnyk 6132 posts 23951 karma points MVP 7x admin c-trib
    Dec 15, 2017 @ 11:29
    Alex Skrypnyk
    0

    Try to wrap method like that:

    @Html.Raw(Umbraco.Field("boothHireBodyText"))
    
  • Damien Green 72 posts 134 karma points
    Dec 15, 2017 @ 11:41
    Damien Green
    0

    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.

  • Alex Skrypnyk 6132 posts 23951 karma points MVP 7x admin c-trib
    Dec 15, 2017 @ 11:43
    Alex Skrypnyk
    0

    Are you using ModelsBuilder? Is it enabled?

  • Damien Green 72 posts 134 karma points
    Dec 15, 2017 @ 11:45
    Damien Green
    0

    I'm not sure, this is a new feature. Does it need to be enabled?

  • Alex Skrypnyk 6132 posts 23951 karma points MVP 7x admin c-trib
    Dec 15, 2017 @ 11:46
    Alex Skrypnyk
    0

    it's better to disable it just after upgrade

  • Damien Green 72 posts 134 karma points
    Dec 15, 2017 @ 11:47
    Damien Green
    0

    Hi Alex, just checked the web.config and it is disabled.

  • Damien Green 72 posts 134 karma points
    Dec 15, 2017 @ 11:52
    Damien Green
    0

    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.

  • Damien Green 72 posts 134 karma points
    Dec 15, 2017 @ 12:02
    Damien Green
    0

    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();
            }
    

    However the equivalent:

    @Model.Content.GetPropertyValue("boothHireBodyText")
    

    Throws the error. This is very strange.

    If I enclose it in Razer tags i.e.

     @{
                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.

  • Damien Green 72 posts 134 karma points
    Dec 15, 2017 @ 14:16
    Damien Green
    100

    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!

  • Alex Skrypnyk 6132 posts 23951 karma points MVP 7x admin c-trib
    Dec 15, 2017 @ 14:36
    Alex Skrypnyk
    0

    I'm really glad that you solved the issue!!! :)

    Have a good beer after work today :)

Please Sign in or register to post replies

Write your reply to:

Draft