Copied to clipboard

Flag this post as spam?

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


  • Vishal Bodakiya 4 posts 74 karma points
    Jul 05, 2024 @ 14:08
    Vishal Bodakiya
    0

    Breaking when making changes in document type

    I am using Umbraco CMS version 13.1.1

    Whenever I am making any changes to properties in document type, the application is breaking and giving below error.

    Both view and content models are in memory generated, with different versions. The application is in an unstable state and should be restarted.

    I already read some posts but i did not find any relevant solution.

    see below error log:

        Umbraco.Cms.Web.Common.ModelBinders.ModelBindingException: Cannot bind source content type Umbraco.Cms.Web.Common.PublishedModels.HomePage to model type Umbraco.Cms.Web.Common.PublishedModels.HomePage. Both view and content models are in memory generated, with different versions. The application is in an unstable state and should be restarted.
       at Umbraco.Cms.Web.Common.ModelBinders.ContentModelBinder.ThrowModelBindingException(Boolean sourceContent, Boolean modelContent, Type sourceType, Type modelType)
       at Umbraco.Cms.Web.Common.Views.UmbracoViewPage`1.BindViewData(ContentModelBinder contentModelBinder, ViewDataDictionary viewData)
       at Umbraco.Cms.Web.Common.Views.UmbracoViewPage`1.set_ViewContext(ViewContext value)
       at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageCoreAsync(IRazorPage page, ViewContext context)
       at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageAsync(IRazorPage page, ViewContext context, Boolean invokeViewStarts)
       at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderAsync(ViewContext context)
       at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, String contentType, Nullable`1 statusCode)
       at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, String contentType, Nullable`1 statusCode)
       at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ActionContext actionContext, IView view, ViewDataDictionary viewData, ITempDataDictionary tempData, String contentType, Nullable`1 statusCode)
       at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewResultExecutor.ExecuteAsync(ActionContext context, ViewResult result)
       at Microsoft.AspNetCore.Mvc.ViewResult.ExecuteResultAsync(ActionContext context)
       at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResultFilterAsync>g__Awaited|30_0[TFilter,TFilterAsync](ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
       at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResultExecutedContextSealed context)
       at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.ResultNext[TFilter,TFilterAsync](State& next, Scope& scope, Object& state, Boolean& isCompleted)
       at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeResultFilters()
    --- End of stack trace from previous location ---
       at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
       at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
       at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
       at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()
    --- End of stack trace from previous location ---
       at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
       at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
       at Umbraco.Cms.Web.Common.Middleware.BasicAuthenticationMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
       at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.InterfaceMiddlewareBinder.<>c__DisplayClass2_0.<<CreateMiddleware>b__0>d.MoveNext()
    --- End of stack trace from previous location ---
       at Umbraco.Cms.Web.BackOffice.Middleware.BackOfficeExternalLoginProviderErrorMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
       at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.InterfaceMiddlewareBinder.<>c__DisplayClass2_0.<<CreateMiddleware>b__0>d.MoveNext()
    --- End of stack trace from previous location ---
       at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
       at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
       at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context)
       at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
       at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
       at StackExchange.Profiling.MiniProfilerMiddleware.Invoke(HttpContext context) in C:\projects\dotnet\src\MiniProfiler.AspNetCore\MiniProfilerMiddleware.cs:line 112
       at Umbraco.Cms.Web.Common.Middleware.UmbracoRequestMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
       at Umbraco.Cms.Web.Common.Middleware.UmbracoRequestMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
       at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.InterfaceMiddlewareBinder.<>c__DisplayClass2_0.<<CreateMiddleware>b__0>d.MoveNext()
    --- End of stack trace from previous location ---
       at Umbraco.Cms.Web.Common.Middleware.PreviewAuthenticationMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
       at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.InterfaceMiddlewareBinder.<>c__DisplayClass2_0.<<CreateMiddleware>b__0>d.MoveNext()
    --- End of stack trace from previous location ---
       at Umbraco.Cms.Web.Common.Middleware.UmbracoRequestLoggingMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
       at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.InterfaceMiddlewareBinder.<>c__DisplayClass2_0.<<CreateMiddleware>b__0>d.MoveNext()
    --- End of stack trace from previous location ---
       at SixLabors.ImageSharp.Web.Middleware.ImageSharpMiddleware.Invoke(HttpContext httpContext, Boolean retry)
       at Microsoft.AspNetCore.Server.IIS.Core.IISHttpContextOfT`1.ProcessRequestAsync()
    
  • Andy Boot 48 posts 190 karma points MVP
    Jul 07, 2024 @ 17:43
    Andy Boot
    0

    Hi Vishal,

    My initial go to thing to check would be to see if your website has previously generated models via Models Builder. Do an initial scan of your project folders for said models, or solution search for HomePage.

    If you've found these files and Umbraco Models Builder is in InMemory mode (check appsettings*.json or within the backoffice under the Models Builder tab of the Settings section) then this would be a good cause for the error you're receiving. Should this be the case, at some stage it would have been set as SourceCodeAuto or SourceCodeManual mode for it to originally generate these files.

    Personally, I'd set to SourceCodeAuto anyways as you're giving yourself multiple benefits such as compile-time/intellisense error checking, ease of debugging, performance, flexibility and extensibility.

    More info on Models Builder can be found here:

    https://docs.umbraco.com/umbraco-cms/v/13.latest-lts/reference/templating/modelsbuilder/builder-modes#sourcecode-models

    and https://docs.umbraco.com/umbraco-cms/v/13.latest-lts/reference/configuration/modelsbuildersettings

    Hope this helps!

    Regards,

    Andy

  • Vishal Bodakiya 4 posts 74 karma points
    Jul 08, 2024 @ 06:21
    Vishal Bodakiya
    0

    Hello,

    First thing is, when I am doing changes in document type and if it is breaking, then it is not only breaking Home page, but it is breaking whole website, so no any pages is working and getting same error(as I added in my original post) for every page. And then I need to publish all the content pages and then all pages working again.

    As you suggested, I done some checks as below.

    See below folder search for model HomePage, I see only cshtml files: FolderSearch

    I have one Models folder, but it is created by me, there is no models folder under path "~/umbraco/models": Project

    In Appsettings.json, I don't have any settings added for ModelsBuilder: appsettings

    In Models Builder tab, it is showing InMemoryAuto, I don't know why: ModelsBuilder

    Still, do I need to set to SourceCodeAuto? If yes, will it break anything on the existing pages after set to SourceCodeAuto or it will work fine as it is?

    Thanks

  • Andy Boot 48 posts 190 karma points MVP
    Jul 08, 2024 @ 07:03
    Andy Boot
    0

    Hmm, yeah give it a go. As I say having the physical models in your code gives you multiple benefits, so no harm done.

Please Sign in or register to post replies

Write your reply to:

Draft