November Happy Hour will be moved to Thursday December 5th.

TemplateDescriptor not working on the integration server (DXC)

Vote:
 

Episerver version: 11.10

I have created a customised FormContainerBlock that uses a controller with TemplateDescriptor.
(Based from https://www.luminary.com/blog/customising-episerver-forms )

Block:

[ContentType(DisplayName = "Form Container Block", GroupName = "Site 2")]
public class Site2FormContainerBlock : FormContainerBlock { }

Controller - the view bag values are getting set from the FormContainerBlockController

[TemplateDescriptor (AvailableWithoutTag = true, Default = true, ModelType = typeof(Site2FormContainerBlock), TemplateTypeCategory = TemplateTypeCategories.MvcPartialController)]
public class Site2FormContainerBlockController: FormContainerBlockController
{
    public override ActionResult Index(FormContainerBlock currentBlock)
   {
         //Call base index for the Client Resource registration but not the view
         //Not needed in case you manually render them in base controller
         base.Index(currentBlock);

        return PartialView("Site2FormContainerBlock", currentBlock);
    }
}


ALL is working well on my local machine.

However, when it had been deployed to the integration server (DXC), the site went straight to the Site2FormContainerBlock.cshtml (ignoring the controller). Thus, displaying an error message due to the ViewBag fields not being set.

Is there any server-side setting that could possibly override the TemplateDescriptor?

Also, when I've checked the Content Type Definition Settings in CMS > Admin > Content Types > Blocks > [Site 2 Form Container Block] > Settings, the controller "Site2FormContainerBlockController" has been listed TWICE under the MVC Dropdown.

#202061
Mar 13, 2019 2:19
Vote:
 

Hi Shella,

Strange that it is working for you locally but not on integration. If I remember correctly the controller is skipped sometimes and I haven't found an exact cause for it. To make sure that it always calls the controller you can give the view a different name than the block model (just like in the blog post where the view name has an underscore). You could try renaming the 'Site2FormContainerBlock' partial view and see if that works.

#202063
Mar 13, 2019 6:47
Vote:
 

Yeah, for now I've moved the CSHTML from the Shared folder to another non-default folder (e.g. /Blocks on Area) and it seemed to work. 

#202094
Mar 13, 2019 23:10
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.