Copied to clipboard

Flag this post as spam?

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

  • Jeffrey Weinstein 67 posts 313 karma points
    Aug 08, 2017 @ 09:23
    Jeffrey Weinstein

    Casting IPublishedContent to Image (PublishedContentModels) type cases app to crash

    I started debugging

    IIS error

    Web server received an invalid response while acting as a gateway or proxy server.
    There is a problem with the page you are looking for, and it cannot be displayed. When the Web server (while acting as a gateway or proxy) contacted the upstream content server, it received an invalid response from the content server.

    I realized this means IIS lost faith in the underlying app and stopped the execution. So my app timed out.

    I looked into the logs of the Umbraco App and found out it is constantly restarting. And last thing it is doing is this:

    Adding examine event handlers for index providers: 3

    Seems like the examine has some problem with my website.

    I found out what was the problem - for homepage I was fetching some additional data from some other pages, combining them and displaying them. For that I casted IPublishedContent to Umbraco.Web.PublishedContentModels.Image .And that caused the whole app to crash.

    Logo = companyDetail.Logo as Image;

    where companyDetail.Logo is

    public IPublishedContent Logo
        get { return this.GetPropertyValue<IPublishedContent>("logo"); }

    So I'm quite perplexed what is the problem here. Can anyone explain what is the problem? I mean I'm using just simple cast and that will break the whole app?

  • Stephen 767 posts 2272 karma points c-trib
    Aug 08, 2017 @ 13:13

    companyDetail.Logo is an IPublishedContent, but is it actually an Image? If the cast fails it probably is not an Image instance. Can you try to output eg "@companyDetail.Logo.GetType()" in your view and see what the actual type is?

  • Jeffrey Weinstein 67 posts 313 karma points
    Aug 08, 2017 @ 15:18
    Jeffrey Weinstein

    Hello Stephen, thanks for prompt reply. It turned out when I started using big IIS locally, I couldn't be more wrong. I was able to attach debugger to w3wp.exe process which was failing and it was with the exception

    An unhandled exception of type 'System.StackOverflowException' occurred in Lucene.Net.dll

    To answer your question, all of the entities I'm passing there have type of Umbraco.Web.PublishedContentModels.Image that's okay, problem is I'm using same pipeline to expose objects thru Rest API, and serialization I think is what causes this. When I exposed directly Umbraco.Web.PublishedContentModels.Image as a property of my model which is used for homepage and also for REST API (this call is executed on homepage also) the above exception happened.

    So it was not the cast, but the serialization. If I create my own model of Image which has Width, Height and Url, it works fine.

    I tried to serialize different PublishedContentModels GenericPage this time and it exploded again, not sure if this is connected to my instance or its problem with Umraco.

Please Sign in or register to post replies

Write your reply to: