Copied to clipboard

Flag this post as spam?

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


  • Maria 34 posts 128 karma points
    Feb 09, 2017 @ 12:02
    Maria
    0

    YSOD when using razor in html attributes

    I've just started a new project in Umbraco version 7.5.8. I've created document types and am about to start writing markup in views by I am getting the strangest error.

    The code below runs without an error. Just as one might expect:

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage<ContentModels.Home2>
    @using ContentModels = Umbraco.Web.PublishedContentModels;
    @{
        Layout = null;
        var sth = 1;
    }
    <a href="">@sth</a>
    

    The same code but with @sth in href attribute causes an error:

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage<ContentModels.Home2>
    @using ContentModels = Umbraco.Web.PublishedContentModels;
    @{
        Layout = null;
        var sth = 1;
    }
    <a href="@sth">@sth</a>
    

    The type name 'Object' does not exist in the type 'Umbraco.Web.PublishedContentModels.System

    The error happens if razor is in class or href attribute but not when it is in data attribute...

    This doesn't seem like an Umbraco error but at the same time this is a pretty simple piece of markup. Any ideas?

  • Alex Skrypnyk 6175 posts 24186 karma points MVP 8x admin c-trib
    Feb 09, 2017 @ 12:55
    Alex Skrypnyk
    0

    Hi Maria

    Did you change something in Umbraco? What about "Home2" docTYpe, is it working fine?

    Thanks,

    Alex

  • Maria 34 posts 128 karma points
    Feb 09, 2017 @ 12:58
    Maria
    0

    I did not change anything in Umbraco. The only thing I did was to create document types and documents.

    Home2 is an empty document type that I used to test the problem. The problem occurs on all other document types. If I don't use razor in attributes all of the document types work.

  • Alex Skrypnyk 6175 posts 24186 karma points MVP 8x admin c-trib
    Feb 09, 2017 @ 13:22
    Alex Skrypnyk
    100

    So strange problem, as you see the error said about "Umbraco.Web.PublishedContentModels.System"

    Maria, do you have System doctype?

    Can you rebuild ModelsBuilder?

    Thanks,

    Alex

  • Maria 34 posts 128 karma points
    Feb 09, 2017 @ 13:31
    Maria
    0

    Yes, I had a documenttype with alias System which was used to collect all settings for the page.

    Changing the alias and rebuilding models solved the problem.

    Thanks so much for coming up with this idea!

    I think this needs to be created as an issue on issue tracker cause that is clearly a nasty bug.

  • Alex Skrypnyk 6175 posts 24186 karma points MVP 8x admin c-trib
    Feb 09, 2017 @ 13:32
    Alex Skrypnyk
    0

    Nice idea - create an issue, I will vote for it, just create please and give me a link. Glad to help! Have a nice day, Maria.

    /Alex

  • Maria 34 posts 128 karma points
    Feb 09, 2017 @ 13:40
Please Sign in or register to post replies

Write your reply to:

Draft