Copied to clipboard

Flag this post as spam?

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


  • Josip 195 posts 662 karma points c-trib
    Feb 15, 2021 @ 15:19
    Josip
    0

    Registering custom view engine

    I need help, how can I do this in Umbraco 8.

    I am following this tutorial for Umbraco 7 made by Kevin Giszewski.

    using Umbraco.Core;
    
    namespace MyNamespace
    {
        public class RegisterViewEngine : ApplicationEventHandler
        {
            protected override void ApplicationStarting(UmbracoApplicationBase umbracoApplication,
                ApplicationContext applicationContext)
            {
                System.Web.Mvc.ViewEngines.Engines.Add(new MyViewEngine());
    
                base.ApplicationStarting(umbracoApplication, applicationContext);
            }
        }
    }
    
  • Nik 1591 posts 7148 karma points MVP 6x c-trib
    Feb 15, 2021 @ 16:52
    Nik
    0

    Hi Josip,

    In order to access similar events in v8, I advise reading this section of the Umbraco documentation: https://our.umbraco.com/Documentation/Reference/Events/Application-Startup

    ApplicationEventHandler no longer exists and has been replaced by a new Dependency Injection based mechanism. The docs are really thorough so have a read and I'm sure you'll be able to crack it :-)

    Cheers

    Nik

  • Danny Summers 5 posts 74 karma points
    Jul 25, 2022 @ 11:31
    Danny Summers
    0

    Did you ever figure this one out? Looking to solve the same problem in a V10 site.

  • Jannik Anker 48 posts 258 karma points c-trib
    Jul 27, 2022 @ 11:23
    Jannik Anker
    0

    Hey Danny,

    You could try adding the view engine in Startup.cs -> ConfigureServices? I don't have a custom view engine to test if it works, though ;-)

    services.AddMvc()
            .AddViewOptions(options =>
                {
                    options.ViewEngines.Add(new MyFancyViewEngine());
                });
    
Please Sign in or register to post replies

Write your reply to:

Draft