Copied to clipboard

Flag this post as spam?

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


  • Tom 161 posts 322 karma points
    Jun 22, 2018 @ 11:02
    Tom
    0

    var imageId = item.GetPropertyValue<int>("backgroundImage"); returning 0 when it should be 1513

    I have upgrade from 7.5.9 to 7.6.5.
    I can login to the backend just find and see my content, doctypes, etc. However, when I launch the site, I am getting an error.

    Here is line of code that is failing in my HeaderCarousel.cshtml macro

    var imageId = item.GetPropertyValue

    Note: This works for string values var bgColor = item.GetPropertyValue

    Question: Did the method get changed for pulling data from macro properties? if not, why is my code returning a 0 when it should return a 1513.

    Here is the full method foreach (var item in Model.CarouselContainer.Children.Where(w => w.GetPropertyValue

                    if (String.IsNullOrWhiteSpace(bgColor))
                    {
                        bgColor = "green";
                    }
                }
                catch (Exception) { /* Supress errors on purpose */ }
    
                **var imageId = item.GetPropertyValue<int>("backgroundImage");**
                var image = 
                UmbracoContext.Current.MediaCache.GetById(imageId);
          }
    

    Does anyone have any suggestions on why this is returning a "0"? var imageId = item.GetPropertyValue

    Thanks Tom

  • Matthew Wise 271 posts 1373 karma points MVP 5x c-trib
    Jun 22, 2018 @ 11:06
    Matthew Wise
    101

    Hi Tom,

    I think this is due to the config setting in config/umbracoSettings.config

     <!-- Enables value converters for all built in property editors so that they return strongly typed object, recommended for use with Models Builder -->
        <EnablePropertyValueConverters>true</EnablePropertyValueConverters>
    

    If you set this to false the site should work again.

    If you want to keep it as true you will need to change your could to use the strongly typed models:

    var image = item.GetPropertyValue<IPublishedContent>("backgroundImage");
    if(image != null)
    {
    ...
    
    }
    

    Hope this helps

    Matt

  • Tom 161 posts 322 karma points
    Jun 22, 2018 @ 11:25
    Tom
    0

    Matt:

    Thank you very much! Setting the value to false fixed it. I am so happy.

    If you have the time, can you tell me which release of Umbraco changed authentication?

    Tom

  • Matthew Wise 271 posts 1373 karma points MVP 5x c-trib
    Jun 22, 2018 @ 11:27
    Matthew Wise
    1

    Glad its fixed :)

    What do you mean by authentication?

    You can compare umbraco Versions here - https://our.umbraco.org/download/releases/compare

    Dont forget to mark the answer it will help others find it :)

    Matt

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jun 22, 2018 @ 11:27
    Jan Skovgaard
    1

    Hi Tom

    This changed with the release of Umbraco 7.6 - See release notes here https://our.umbraco.org/download/releases/760/

    It's also marked with red under the "Upgrade" section on the page :)

    /Jan

  • Tom 161 posts 322 karma points
    Jun 22, 2018 @ 11:32
    Tom
    0

    Matt:

    We use Active Directory for our authentication. Does this get broken when I upgrade to 7.7.5 or 7.7.6?

    Tom

  • Matthew Wise 271 posts 1373 karma points MVP 5x c-trib
    Jun 22, 2018 @ 11:37
    Matthew Wise
    1

    Nothing should of changed for just a minor version, certainly not a breaking one.

    I would give your config settings a once over make sure nothing has changed that shouldn't of.

    https://our.umbraco.org/download/releases/compare?from=7.5.9&to=7.6.5

    ill show you all the documented changes, so there maybe something there but I couldn't see anything.

    Matt

  • Tom 161 posts 322 karma points
    Jun 22, 2018 @ 12:00
    Tom
    0

    Thanks Matt.

  • Tom 161 posts 322 karma points
    Jun 22, 2018 @ 14:18
    Tom
    0

    Matt:

    I hope you are still around,. I just upgraded from 7.6.5 to 7.7.0 and I am getting this error (see below) which is coming from my customOwinStartup class for Active Directory

    Method not found: 'Void Umbraco.Core.Security.BackOfficeUserStore..ctor(Umbraco.Core.Services.IUserService, Umbraco.Core.Services.IExternalLoginService, Umbraco.Core.Security.MembershipProviderBase)'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.MissingMethodException: Method not found: 'Void Umbraco.Core.Security.BackOfficeUserStore..ctor(Umbraco.Core.Services.IUserService, Umbraco.Core.Services.IExternalLoginService, Umbraco.Core.Security.MembershipProviderBase)'.

    Source Error:

    Line 46: Line 47: return FhlbBackOfficeUserManager.InitUserManager(new FhlbBackOfficeUserManager(store), membershipProvider, options); Line 48: }); Line 49: Line 50: //Ensure owin is configured for Umbraco back office authentication

    Source File: D:\Source\repos\PublicWebSite\Mantle.core\Security\UmbracoCustomOwinStartup.cs Line: 48

    Stack Trace:

    [MissingMethodException: Method not found: 'Void Umbraco.Core.Security.BackOfficeUserStore..ctor(Umbraco.Core.Services.IUserService, Umbraco.Core.Services.IExternalLoginService, Umbraco.Core.Security.MembershipProviderBase)'.] Mantle.core.Security.<>cDisplayClass10.0(IdentityFactoryOptions`1 options, IOwinContext context) in D:\Source\repos\PublicWebSite\Mantle.core\Security\UmbracoCustomOwinStartup.cs:48 Microsoft.AspNet.Identity.Owin.

    Here is the contents of my class.
    Can you offer any assistance?

    using Mantle.core.Security; using Microsoft.Owin; using Owin; using Umbraco.Core; using Umbraco.Core.Models.Identity; using Umbraco.Core.Security; using Umbraco.Web.Security.Identity;

    //To use this startup class, change the appSetting value in the web.config called // "owin:appStartup" to be "UmbracoCustomOwinStartup"

    [assembly: OwinStartup("UmbracoCustomOwinStartup", typeof(UmbracoCustomOwinStartup))]

    namespace Mantle.core.Security { ///

    /// A custom way to configure OWIN for Umbraco /// /// public class UmbracoCustomOwinStartup {

        private static readonly log4net.ILog Log = log4net.LogManager.GetLogger(typeof(UmbracoCustomOwinStartup));
    
        public void Configuration(IAppBuilder app)
        {
            app.SanitizeThreadCulture();
    
            app.SetUmbracoLoggerFactory();
    
            //Configure the Identity user manager for use with Umbraco Back office
            var appCtx = ApplicationContext.Current;
            app.ConfigureUserManagerForUmbracoBackOffice<BackOfficeUserManager, BackOfficeIdentityUser>(
                appCtx,
                (options, context) =>
                {
                    var membershipProvider = MembershipProviderExtensions.GetUsersMembershipProvider().AsUmbracoMembershipProvider();
                    var store = new BackOfficeUserStore(
                        appCtx.Services.UserService,
                        appCtx.Services.ExternalLoginService,
                        membershipProvider);
    
                    return FhlbBackOfficeUserManager.InitUserManager(new FhlbBackOfficeUserManager(store), membershipProvider, options);
                });
    
            //Ensure owin is configured for Umbraco back office authentication
            app.UseUmbracoBackOfficeCookieAuthentication(ApplicationContext.Current)
                .UseUmbracoBackOfficeExternalCookieAuthentication(ApplicationContext.Current)
                .UseUmbracoPreviewAuthentication(ApplicationContext.Current);
    
            Log.Debug(@"AD Authentication initialized");
        }
    }
    

    }

  • Matthew Wise 271 posts 1373 karma points MVP 5x c-trib
    Jun 22, 2018 @ 14:40
    Matthew Wise
    0

    Not done any custom Owin stuff unfortunately, it might be worth creating a new post.

    I know the user permissions have moved to groups now so that may be part of the issue.

    Matt

  • Tom 161 posts 322 karma points
    Jun 22, 2018 @ 14:41
    Tom
    0

    OK will do. Thanks for trying. Have a great upcoming weekend.

  • Tom 161 posts 322 karma points
    Jun 22, 2018 @ 15:28
    Tom
    0

    Matt:

    I recall for 7.7 I needed to login using the admin email account. I also changed the authentication from our custom OWN startup class to the UmbracoDefaultOwinStartup. When I did this and reset IIS, I was able to log in using [email protected].
    But now I am getting a blank screen. When I go to SQL Server and refresh the database, I don't see any new tables.

    Is this expected?

    Tom

  • Tom 161 posts 322 karma points
    Jun 22, 2018 @ 15:30
    Tom
    0

    Do you know what new tables are added with 7.7?

  • Tom 161 posts 322 karma points
    Jun 22, 2018 @ 18:07
    Tom
    0

    Nevermind I found them

Please Sign in or register to post replies

Write your reply to:

Draft