Adding own ViewEngine breaks backend

Posted by Community Admin on 04-Aug-2018 15:47

Adding own ViewEngine breaks backend

All Replies

Posted by Community Admin on 24-Sep-2013 00:00

Hi,
I implemented my own ViewEngine(inherited from RazorViewEngine od course)
I needed to do that so I can use the _viewStart/Layout.cshtml mechanism.

In global.asax.cs I added the Engine
protected void Application_Start(object sender, EventArgs e)
       

            Telerik.Sitefinity.Abstractions.Bootstrapper.Initialized += new EventHandler<Telerik.Sitefinity.Data.ExecutedEventArgs>(Bootstrapper_Initialized);

            Telerik.Sitefinity.Abstractions.Bootstrapper.MVC.MapRoute(
               "AjaxCall", // Route name
               "ajax/controller/action/id", // URL with parameters
               new controller = "Hausrat", action = "Index", id = UrlParameter.Optional
           );

            ClientDataTypeModelValidatorProvider.ResourceClassKey = "ErrorDateTypeMessages";
            DefaultModelBinder.ResourceClassKey = "ErrorDateTypeMessages";



            //PowerTools.Instance
            //        .RootTemplates
            //        .RegisterMvcTemplateResolver<CustomMvcTemplateResolver>();
            

            // register bundles
            BundleConfig.RegisterBundles(BundleTable.Bundles);
       

        void Bootstrapper_Initialized(object sender, Telerik.Sitefinity.Data.ExecutedEventArgs e)
       

            if (e.CommandName == "RegisterRoutes")
           
                RegisterRoutes(RouteTable.Routes);
           

            if (e.CommandName == "Bootstrapped")
           
                ViewEngines.Engines.Add(new XitasoSiteFinityViewEngine()); <--
           
       

But after that I broke the edit content backend action.
if i navigate to pagename/Action/Edit I get redirected to the normal view of the page localhost/pagename

Any idea how to prevent this behavior?

Regards,

Christian

Posted by Community Admin on 25-Sep-2013 00:00

Hello,

Can you give us an idea of what you are trying to ultimately accomplish? There might be an easier way to do this, but we want to make sure we understand your requirements first.

Regards,
David C
Telerik
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 26-Sep-2013 00:00

Hi there,

was my fault.
i missed a RedirectToAction in the Index() Action.
Now it works.

The idea behind this is to integrate an existing MVC application as widgets.
So i set all the JavaScript and Css paths in the _Layout.cshtml, which is is set by _viewStart.cshtml.
The hole process is triggert by my own ViewEngine:
protected override IView CreateView(ControllerContext controllerContext, string viewPath, string masterPath)
           
                var newViewEngine = new RazorView(
                    controllerContext,
                    viewPath,
                    masterPath,
                    true, //<--- this drives whether to use _ViewStart pages.  It was set to false
                    FileExtensions,
                    ViewPageActivator
                );

                return newViewEngine;
           


Regards,

Christian

This thread is closed