Copied to clipboard

Flag this post as spam?

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


  • Marius Olbert 2 posts 72 karma points
    Mar 31, 2016 @ 16:24
    Marius Olbert
    0

    ModelsBuilder

    Hi Umbraco Community,

    I am developing the site for the client and have the following structure in my backend. Home -> News&Events -> Events -> Events Item

    When I try to access on frontend my event item. It shows the following error

    Cannot bind source content type Umbraco.Web.PublishedContentModels.EventItem to model content type Umbraco.Web.PublishedContentModels.Master.
    
    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: Umbraco.Web.Mvc.ModelBindingException: Cannot bind source content type Umbraco.Web.PublishedContentModels.EventItem to model content type Umbraco.Web.PublishedContentModels.Master.
    
    Source Error: 
    
    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
    
    Stack Trace: 
    
    
    [ModelBindingException: Cannot bind source content type Umbraco.Web.PublishedContentModels.EventItem to model content type Umbraco.Web.PublishedContentModels.Master.]
       Umbraco.Web.Mvc.RenderModelBinder.ThrowModelBindingException(Boolean sourceContent, Boolean modelContent, Type sourceType, Type modelType) +641
       Umbraco.Web.Mvc.RenderModelBinder.BindModel(Object source, Type modelType, CultureInfo culture) +437
       Umbraco.Web.Mvc.UmbracoViewPage`1.SetViewData(ViewDataDictionary viewData) +225
       System.Web.Mvc.WebViewPage.set_ViewData(ViewDataDictionary value) +24
       System.Web.Mvc.WebViewPage.ConfigurePage(WebPageBase parentPage) +78
       System.Web.WebPages.<>c__DisplayClass3.<RenderPageCore>b__2(TextWriter writer) +198
       System.Web.WebPages.HelperResult.WriteTo(TextWriter writer) +27
       System.Web.WebPages.WebPageExecutingBase.WriteTo(TextWriter writer, HelperResult content) +31
       System.Web.WebPages.WebPageBase.Write(HelperResult result) +32
       System.Web.WebPages.WebPageBase.RenderSurrounding(String partialViewName, Action`1 body) +101
       System.Web.WebPages.WebPageBase.PopContext() +146
       System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +120
       System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +312
       System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) +115
       Umbraco.Core.Profiling.ProfilingView.Render(ViewContext viewContext, TextWriter writer) +93
       System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +248
       System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +27
       System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +58
       System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +349
       System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +349
       System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +349
       System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +69
       System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInvokeAction>b__1c() +188
       System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +124
       System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +27
       System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +58
       System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +30
       System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +29
       System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +27
       System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +48
       System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +58
       System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +30
       System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +21
       System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +32
       System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult asyncResult, Controller controller) +26
       System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +40
       System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +58
       System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +30
       System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +21
       System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +29
       System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +24
       System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +27
       System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +48
       System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +58
       System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +30
       System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +21
       System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +29
       System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +23
       System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9744373
       System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155.
    

    Can someone guide me how to fix it??

    Thanks

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Apr 01, 2016 @ 05:51
    Jan Skovgaard
    1

    Hi Marius and welcome to our :)

    It would be a bit easier to help you out if you could show us the code you're trying to use in order to render some data.

    Looking forward to hearing from you.

    /Jan

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Apr 01, 2016 @ 05:55
    Jan Skovgaard
    0

    Hi again

    Sorry misread the question initially.

    This is just something that happens before you even try to render anything?

    What is the exact version of Umbraco 7 you're using?

    Perhaps some of the discusssion on using the models builder here can help? https://our.umbraco.org/forum/umbraco-7/using-umbraco-7/75079-74-models-builder

    Stephan who developed the models builder blogs about it here http://www.zpqrtbnk.net/posts/

    There is more documentation about it here https://github.com/zpqrtbnk/Zbu.ModelsBuilder/wiki - If you're using 7.4 then you should read about version 3.

    Hope this can help somewhat.

    /Jan

  • Marius Olbert 2 posts 72 karma points
    Apr 01, 2016 @ 07:36
    Marius Olbert
    0

    Hi Jan,

    I am using Umbraco 7.4.2. This happens when I try to access event item from front end. If I put layout = null then I am able to access. This is the bit of code I have on my event Item template

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @using ContentModels = Umbraco.Web.PublishedContentModels;
    @{
        Layout = "_Master.cshtml";
    }
    
    <section id="singleEvent">
        <div class="row">
            <div class="col-lg-4 col-md-4 col-sm-4">
                <a href="#" title="Back to News & Events">News & Events</a>
                <h1>@CurrentPage.eventTitle</h1>
            </div>
            <div class="col-lg-8 col-md-8 col-sm-8">
    
            </div>
        </div>
    </section>
    
Please Sign in or register to post replies

Write your reply to:

Draft