Copied to clipboard

Flag this post as spam?

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


  • Philip Hayton 98 posts 435 karma points
    Oct 26, 2019 @ 14:16
    Philip Hayton
    1

    Return Umbraco 404 from RenderMvcController

    Hi guys,

    Is it possible, and if so how do you return the standard Umbraco 404 error from a RenderMvcController? This beautiful bad boy:

    enter image description here

    In my scenario, I am using a UmbracoVirtualNodeRouteHandler to handle a custom route. A RenderMvcController is responsible for pulling the content from a remote API via ID. If the content doesn't exist, I'd like to return the same 404 page generated by normal Umbraco routing.

    Here's how I'm currently doing it. This returns an IIS error page though.

            var remoteContent = await _service.Get(id);
            if (remoteContent == null) return new HttpNotFoundResult();
    

    Any help is greatly appreciated. TIA!

Please Sign in or register to post replies

Write your reply to:

Draft