Adding own ViewEngine breaks backend
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
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,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