I've got a page with 2 custom widgets (header and footer) and a MVC news widget which displays a list of all blog posts.
The individual / single news pages don't render my custom widgets.
I've come across solutions that have suggested to override the HandleUnknownAction. I've tried multiple variations in my custom widget controllers but they haven't worked. On the frontend, where the widget would be rendered, I'm getting an error message on the frontend: 'Exception occured while executing the controller. Check error logs for details'.
At this point I'm assuming there may be something incorrect in my controller so I've attached the entire contents of one of the custom widgets:
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Telerik.Sitefinity.Mvc;
using EuroChange.DLL;
using EuroChange.BLL;
using SitefinityWebApp.Mvc.Models.BranchLocator;
using SitefinityWebApp.Filter;
using EuroChange.DLL.Data;
using Telerik.Sitefinity.Model.Localization;
using Telerik.Sitefinity.Publishing;
using Telerik.Sitefinity.Services;
using Telerik.Sitefinity.Services.Search;
using Telerik.Sitefinity.Services.Search.Data;
using Telerik.Sitefinity.Services.Search.Model;
using Telerik.Sitefinity.Services.Search.Publishing;
using System.Globalization;
using Telerik.Sitefinity.Modules.News;
using SitefinityWebApp.Mvc.Models;
using System.Web.Script.Serialization;
using Telerik.Sitefinity.Frontend.Designers;
using Telerik.Sitefinity.Frontend.Lists.Mvc.Controllers;
namespace SitefinityWebApp.Mvc.Controllers
{
[ControllerToolboxItem(Name = "SPfooterPrimaryLinks", Title = "Footer Primary Links", SectionName = "SP Widgets")]
public class SPfooterPrimaryLinksController : Controller
{
public string ListButtons { get; set; }
public string ListButtonsTwo { get; set; }
public string ListButtonsThree { get; set; }
public string ListButtonsFour { get; set; }
public string ListButtonsFive { get; set; }
public string ListButtonsSix { get; set; }
public string ListButtonsSeven { get; set; }
public string ListButtonsEight { get; set; }
public ActionResult Index()
{
this.ViewBag.ListButtons = this.DeserializeItems();
this.ViewBag.ListButtonsTwo = this.DeserializeItemsTwo();
this.ViewBag.ListButtonsThree = this.DeserializeItemsThree();
this.ViewBag.ListButtonsFour = this.DeserializeItemsFour();
this.ViewBag.ListButtonsFive = this.DeserializeItemsFive();
this.ViewBag.ListButtonsSix = this.DeserializeItemsSix();
this.ViewBag.ListButtonsSeven = this.DeserializeItemsSeven();
this.ViewBag.ListButtonsEight = this.DeserializeItemsEight();
return this.View();
}
protected override void HandleUnknownAction(string actionName)
{
// this.ActionInvoker.InvokeAction(this.ControllerContext, "Index");
//Index().ExecuteResult(ControllerContext);
//View("Index").ExecuteResult(this.ControllerContext);
this.Index().ExecuteResult(this.ControllerContext);
}
private IList<SPfooterPrimaryLinksModel> DeserializeItems()
{
var serializer = new JavaScriptSerializer();
IList<SPfooterPrimaryLinksModel> buttons = new List<SPfooterPrimaryLinksModel>();
if (!string.IsNullOrEmpty(this.ListButtons))
buttons = serializer.Deserialize<IList<SPfooterPrimaryLinksModel>>(this.ListButtons);
return buttons;
}
private IList<SPfooterPrimaryLinksTwoModel> DeserializeItemsTwo()
{
var serializer = new JavaScriptSerializer();
IList<SPfooterPrimaryLinksTwoModel> buttonsTwo = new List<SPfooterPrimaryLinksTwoModel>();
if (!string.IsNullOrEmpty(this.ListButtonsTwo))
buttonsTwo = serializer.Deserialize<IList<SPfooterPrimaryLinksTwoModel>>(this.ListButtonsTwo);
return buttonsTwo;
}
private IList<SPfooterPrimaryLinksThreeModel> DeserializeItemsThree()
{
var serializer = new JavaScriptSerializer();
IList<SPfooterPrimaryLinksThreeModel> buttonsThree = new List<SPfooterPrimaryLinksThreeModel>();
if (!string.IsNullOrEmpty(this.ListButtonsThree))
buttonsThree = serializer.Deserialize<IList<SPfooterPrimaryLinksThreeModel>>(this.ListButtonsThree);
return buttonsThree;
}
private IList<SPfooterPrimaryLinksFourModel> DeserializeItemsFour()
{
var serializer = new JavaScriptSerializer();
IList<SPfooterPrimaryLinksFourModel> buttonsFour = new List<SPfooterPrimaryLinksFourModel>();
if (!string.IsNullOrEmpty(this.ListButtonsFour))
buttonsFour = serializer.Deserialize<IList<SPfooterPrimaryLinksFourModel>>(this.ListButtonsFour);
return buttonsFour;
}
private IList<SPfooterPrimaryLinksFiveModel> DeserializeItemsFive()
{
var serializer = new JavaScriptSerializer();
IList<SPfooterPrimaryLinksFiveModel> buttonsFive = new List<SPfooterPrimaryLinksFiveModel>();
if (!string.IsNullOrEmpty(this.ListButtonsFive))
buttonsFive = serializer.Deserialize<IList<SPfooterPrimaryLinksFiveModel>>(this.ListButtonsFive);
return buttonsFive;
}
private IList<SPfooterPrimaryLinksSixModel> DeserializeItemsSix()
{
var serializer = new JavaScriptSerializer();
IList<SPfooterPrimaryLinksSixModel> buttonsSix = new List<SPfooterPrimaryLinksSixModel>();
if (!string.IsNullOrEmpty(this.ListButtonsSix))
buttonsSix = serializer.Deserialize<IList<SPfooterPrimaryLinksSixModel>>(this.ListButtonsSix);
return buttonsSix;
}
private IList<SPfooterPrimaryLinksSevenModel> DeserializeItemsSeven()
{
var serializer = new JavaScriptSerializer();
IList<SPfooterPrimaryLinksSevenModel> buttonsSeven = new List<SPfooterPrimaryLinksSevenModel>();
if (!string.IsNullOrEmpty(this.ListButtonsSeven))
buttonsSeven = serializer.Deserialize<IList<SPfooterPrimaryLinksSevenModel>>(this.ListButtonsSeven);
return buttonsSeven;
}
private IList<SPfooterPrimaryLinksEightModel> DeserializeItemsEight()
{
var serializer = new JavaScriptSerializer();
IList<SPfooterPrimaryLinksEightModel> buttonsEight = new List<SPfooterPrimaryLinksEightModel>();
if (!string.IsNullOrEmpty(this.ListButtonsEight))
buttonsEight = serializer.Deserialize<IList<SPfooterPrimaryLinksEightModel>>(this.ListButtonsEight);
return buttonsEight;
}
}
}
Update These are the error logs from the offending page:
08/17/2020 22:46:39
Type : System.Reflection.TargetInvocationException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Message : Exception has been thrown by the target of an invocation.
Source : mscorlib
Help link :
Data : System.Collections.ListDictionaryInternal
TargetSite : System.Object InvokeMethod(System.Object, System.Object[], System.Signature, Boolean)
HResult : -2146232828
Stack Trace : at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Telerik.Sitefinity.Mvc.ControllerWrapper.CallHandleUnknownAction(String actionName)
at Telerik.Sitefinity.Mvc.ControllerWrapper.Execute()
at Telerik.Sitefinity.Mvc.ControllerActionInvoker.ExecuteController(MvcProxyBase proxyControl)
at Telerik.Sitefinity.Frontend.Mvc.Infrastructure.Routing.FeatherActionInvoker.ExecuteController(MvcProxyBase proxyControl)
Additional Info:
MachineName : DESKTOP-057IG4E
TimeStamp : 08/17/2020 21:46:39
FullName : Telerik.Sitefinity.Utilities, Version=9.2.6211.0, Culture=neutral, PublicKeyToken=b28c218413bdf563
AppDomainName : /LM/W3SVC/3/ROOT-1-132421743230335362
ThreadIdentity :
WindowsIdentity : IIS APPPOOL\NM-Money
Requested URL : https://localhost:44651/news/2018/05/06/ready-steady-go!
Inner Exception
---------------
Type : System.InvalidOperationException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Message : The view '2018' or its master was not found or no view engine supports the searched locations. The following locations were searched:
~/Views/SPfooterPrimaryLinks/2018.cshtml
~/Views/Shared/2018.cshtml
~/Frontend-Assembly/SitefinityWebApp/Mvc/Views/SPfooterPrimaryLinks/2018.cshtml
~/Frontend-Assembly/SitefinityWebApp/Mvc/Views/Shared/2018.cshtml
~/Frontend-Assembly/Telerik.Sitefinity.Frontend/Mvc/Views/SPfooterPrimaryLinks/2018.cshtml
~/Frontend-Assembly/Telerik.Sitefinity.Frontend/Mvc/Views/Shared/2018.cshtml
~/Views/SPfooterPrimaryLinks/2018.aspx
~/Views/SPfooterPrimaryLinks/2018.ascx
~/Views/Shared/2018.aspx
~/Views/Shared/2018.ascx
~/Frontend-Assembly/SitefinityWebApp/Mvc/Views/SPfooterPrimaryLinks/2018.aspx
~/Frontend-Assembly/SitefinityWebApp/Mvc/Views/SPfooterPrimaryLinks/2018.ascx
~/Frontend-Assembly/SitefinityWebApp/Mvc/Views/Shared/2018.aspx
~/Frontend-Assembly/SitefinityWebApp/Mvc/Views/Shared/2018.ascx
~/Frontend-Assembly/Telerik.Sitefinity.Frontend/Mvc/Views/SPfooterPrimaryLinks/2018.aspx
~/Frontend-Assembly/Telerik.Sitefinity.Frontend/Mvc/Views/SPfooterPrimaryLinks/2018.ascx
~/Frontend-Assembly/Telerik.Sitefinity.Frontend/Mvc/Views/Shared/2018.aspx
~/Frontend-Assembly/Telerik.Sitefinity.Frontend/Mvc/Views/Shared/2018.ascx
~/Views/SPfooterPrimaryLinks/2018.vbhtml
~/Views/Shared/2018.vbhtml
~/Frontend-Assembly/SitefinityWebApp/Mvc/Views/SPfooterPrimaryLinks/2018.vbhtml
~/Frontend-Assembly/SitefinityWebApp/Mvc/Views/Shared/2018.vbhtml
~/Frontend-Assembly/Telerik.Sitefinity.Frontend/Mvc/Views/SPfooterPrimaryLinks/2018.vbhtml
~/Frontend-Assembly/Telerik.Sitefinity.Frontend/Mvc/Views/Shared/2018.vbhtml
Source : System.Web.Mvc
Help link :
Data : System.Collections.ListDictionaryInternal
TargetSite : System.Web.Mvc.ViewEngineResult FindView(System.Web.Mvc.ControllerContext)
HResult : -2146233079
Stack Trace : at System.Web.Mvc.ViewResult.FindView(ControllerContext context)
at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context)
at SitefinityWebApp.Mvc.Controllers.SPfooterPrimaryLinksController.HandleUnknownAction(String actionName) in C:\dev\Sites\NM-Money\EChange\Mvc\Controllers\SPfooterPrimaryLinks\SPfooterPrimaryLinksController.cs:line 62
Category: ErrorLog
Priority: 0
EventId: 9010
Severity: Warning
Title:Enterprise Library Exception Handling
Machine: DESKTOP-057IG4E
App Domain: /LM/W3SVC/3/ROOT-1-132421743230335362
ProcessId: 3256
Process Name: c:\windows\system32\inetsrv\w3wp.exe
Thread Name:
Win32 ThreadId:10092
Extended Properties: