Copied to clipboard

Flag this post as spam?

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


  • Tom Engan 430 posts 1173 karma points
    Sep 25, 2017 @ 12:30
    Tom Engan
    0

    Multiple errors after upgrading from Umbraco 7.6.5 to 7.7.1

    This is from a partial view:

    @inherits UmbracoViewPage<Neoweb.Models.HikingDestinationViewModel>
    

    The type or namespace name 'UmbracoViewPage<>' could not be found (are you missing a using directive or an assembly reference?)

    @Umbraco.Field("hikingDestinationPoints")
    

    The type or namespace name 'Field' does not exist in the namespace 'Umbraco' (are you missing an assembly reference?)

    @foreach (var visit in Model.Visits)
    {
        ....
    }
    

    The name 'Model' does not exist in the current context


    And from a surface controller:

    else if (umbraco.helper.GetCurrentUmbracoUser().UserType.Alias == "admin")
    {
        ....
    }
    

    Error CS1061 'User' does not contain a definition for 'UserType' and no extension method 'UserType' accepting a first argument of type 'User' could be found (are you missing a using directive or an assembly reference?)

     IEnumerable<IPublishedContent> pages = UmbracoHelper.TypedContent(NodeId).Descendants("hikingDestination").Where("Visible");
    

    Warning CS0618 'PublishedContentExtensions.Where(IEnumerable


    Someone who knows some of these error messages?

  • Alex Skrypnyk 6182 posts 24283 karma points MVP 8x admin c-trib
    Sep 25, 2017 @ 12:45
    Alex Skrypnyk
    1

    Hi Tom

    Replace this line:

     IEnumerable<IPublishedContent> pages = UmbracoHelper.TypedContent(NodeId).Descendants("hikingDestination").Where("Visible");
    

    with this one:

    IEnumerable<IPublishedContent> pages = Umbraco.TypedContent(NodeId).Descendants().Where(x => x.IsVisible() && x.DocumentTypeAlias.Equals("hikingDestination"));
    

    Also, do not use "Descendants"!

    Thanks,

    Alex

  • Tom Engan 430 posts 1173 karma points
    Sep 25, 2017 @ 12:52
    Tom Engan
    0

    Thank you, it worked according to IntelliSense. One error less. :-)

  • Alex Skrypnyk 6182 posts 24283 karma points MVP 8x admin c-trib
    Sep 25, 2017 @ 13:02
    Alex Skrypnyk
    0
    @Umbraco.Field("hikingDestinationPoints")
    

    =>

    @Umbraco.AssignedContentItem.GetPropertyValue("hikingDestinationPoints")
    
  • Tom Engan 430 posts 1173 karma points
    Sep 25, 2017 @ 13:07
    Tom Engan
    0

    I still get the "The type or namespace name 'AssignedContentItem' does not exist in the namespace 'Umbraco' (are you missing an assembly reference?)" message.

    In the top of the partial view, I have used:

    @inherits UmbracoViewPage<Neoweb.Models.HikingDestinationViewModel>
    

    Do you have a suggestion of what will work now as we have come to version 7.7.1?

  • Alex Skrypnyk 6182 posts 24283 karma points MVP 8x admin c-trib
    Sep 25, 2017 @ 13:24
    Alex Skrypnyk
    0

    I'm using Umbraco 7.7.1 and it works for me.

    Can you show all the code of your view?

    Thanks,

    Alex

  • Alex Skrypnyk 6182 posts 24283 karma points MVP 8x admin c-trib
    Sep 25, 2017 @ 13:24
    Alex Skrypnyk
    0

    Tom, have a look at /views/web.config

    There should be section:

      <system.web.webPages.razor>
        <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <pages pageBaseType="System.Web.Mvc.WebViewPage">
          <namespaces>
            <add namespace="System.Web.Mvc" />
            <add namespace="System.Web.Mvc.Ajax" />
            <add namespace="System.Web.Mvc.Html" />
            <add namespace="System.Web.Routing" />
            <add namespace="Umbraco.Web" />
            <add namespace="Umbraco.Core" />
            <add namespace="Umbraco.Core.Models" />
            <add namespace="Umbraco.Web.Mvc" />
            <add namespace="umbraco" />
            <add namespace="Examine" />
            <add namespace="Umbraco.Web.PublishedContentModels" />        
          </namespaces>
        </pages>
      </system.web.webPages.razor>
    
  • Tom Engan 430 posts 1173 karma points
    Sep 25, 2017 @ 13:38
    Tom Engan
    0

    This is the partial view:

    @inherits UmbracoViewPage<Neoweb.Models.HikingDestinationViewModel>
    
    <div class="contentPadding panel panel-primary" style="margin-top: 5px">
        <p style="background-color: #efefef; padding:1px 0 1px 5px">@Umbraco.AssignedContentItem.GetPropertyValue("hikingDestinationPoints")</p>
        <p style="background-color: #efefef; margin-top: -10px; padding:1px 0 1px 5px">@Umbraco.AssignedContentItem.GetPropertyValue("distance")</p>
        <p style="background-color: #efefef; margin-top: -10px; padding:1px 0 1px 5px">@Umbraco.AssignedContentItem.GetPropertyValue("timeSpent")</p>
            <hr style="border-style: dotted; margin-top: 5px" />
            <h4 style="margin-bottom: 15px">Flest besøk i @DateTime.Now.Year:</h4>
    
            <table style="margin-bottom: 10px">
                <tr>
                    <th style="padding-left:5px">Navn</th>
                    <th style="text-align: center">Ant.</th>
                    <th style="text-align: center">Poeng</th>
                </tr>
                @foreach (var visit in Model.Visits)
                {
                    <tr>
                        <td style="padding-left:5px">@visit.HikerName</td>
                        <td style="text-align: center">@visit.NumberOfVisits</td>
                        <td style="text-align: center">@visit.NumberOfPoints</td>
                    </tr>
                }
                @if (Model.Visits.Count == 0)
                {
                    <tr>
                        <td style="padding-left:5px" colspan="3">Ingen godkjente turmål</td>
                    </tr>
                }
            </table>
    </div>
    

    I have the <system.web.webPages.razor> section at /views/web.config, but my bin folder is empty. Is it here something has gone wrong while upgrading?

  • Alex Skrypnyk 6182 posts 24283 karma points MVP 8x admin c-trib
    Sep 25, 2017 @ 14:33
    Alex Skrypnyk
    0

    definitely, bin folder can't be empty

  • Tom Engan 430 posts 1173 karma points
    Sep 25, 2017 @ 13:56
    Tom Engan
    0

    I see now I have many more errors after upgrading, so something has gone wrong.

    enter image description here

  • Alex Skrypnyk 6182 posts 24283 karma points MVP 8x admin c-trib
    Sep 25, 2017 @ 14:35
    Alex Skrypnyk
    0

    Please, try to find out why bin folder is empty.

  • Tom Engan 430 posts 1173 karma points
    Sep 25, 2017 @ 14:38
    Tom Engan
    0

    Fortunately, I took backup, so now I've upgraded my solution again. First from 7.6.5 to 7.6.8, then from 7.6.8. to 7.7.1, and now Umbraco works as it should again. :-)

    All I have to figure out is the changes Umbraco has done with User, so it's the one that needs to be renewed:

    if (umbraco.helper.GetCurrentUmbracoUser().UserType.Alias == "admin")
    

    'User' does not contain a definition for 'UserType' and no extension method 'UserType' accepting a first argument of type 'User' could be found (are you missing a using directive or an assembly reference?)

  • Alex Skrypnyk 6182 posts 24283 karma points MVP 8x admin c-trib
    Sep 25, 2017 @ 14:44
    Alex Skrypnyk
    100

    Tom, I'm not sure that this is 100% perfect code, but it works for me:

    @if (ApplicationContext.Services.UserService.GetUserById(helper.GetCurrentUmbracoUser().Id).Groups.FirstOrDefault(x => x.Alias.Equals("admin")) != null)
    
  • Tom Engan 430 posts 1173 karma points
    Sep 25, 2017 @ 14:53
    Tom Engan
    0

    Thank you very much, appreciate your helpfulness. It was the last piece for this thread, and the upgrade is now complete.

  • Alex Skrypnyk 6182 posts 24283 karma points MVP 8x admin c-trib
    Sep 25, 2017 @ 14:53
    Alex Skrypnyk
    1

    You are welcome, Tom, have a great evening!

    Alex

Please Sign in or register to post replies

Write your reply to:

Draft