Hi Team,
I have created custom controller widget as below :
namespace MvcSpaDemo.MVC.Controllers
{
[ControllerToolboxItem(Name = "Test", Title = "Test", SectionName = "Test SPA")]
public class TestController : Controller
{
// GET: Test
public ActionResult Index()
{
return View("/MVC/Views/Test/Index.cshtml");
}
}
}
When i do drag and drop of custom widget on sitefinity page, getting below error in sitefinity log :
Message: HandlingInstanceID: c08f5376-631c-4907-9078-d76755ba8e10
An exception of type 'System.InvalidOperationException' occurred and was caught.
--------------------------------------------------------------------------------
02/12/2019 09:41:43
Type : System.InvalidOperationException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Message : The view '/MVC/Views/Test/Index.cshtml' or its master was not found or no view engine supports the searched locations. The following locations were searched:
/MVC/Views/Test/Index.cshtml
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 System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult)
at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, 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)
i got couple of post regarding the same post but nothing worked out for me. Does anyone know workaround for this?
Currently i am using Sitefinity 11.0 & .Net framework 4.7 for developing my application.
Regards,
Krishan
Hi,
I assume you've already checked whether the view file actually exists :)
Try one of the following
1) use "~/MVC/..." (tilde in the front)
2) use simply "Index" as name instead of the full path and .cshtml
pls. let me know if it helped.
BR
David
Hi David,
I have checked the location of view and its present over there. Also, i did try your suggestion but no luck. To add more on issue, i have 2-project in solution as below :
1. MvcSpaDemo - (My controller model and view exist in this project)
2. SitefinityWebApp - (Created through CMS project manager by Sitefinity)
Adding the reference of MvcSpaDemo DLL in SitefinityWebApp. I can see my custom widget in sitefinity console and able to drag on custom page. While i am viewing the page, getting view can't be found error.
Hope it will help you to understand the problem a bit more.
Regards,
Krishan
Hi Krishan,
Thanks for the hint, that explains the problem indeed.
When the widget is in a different assembly than the SitefinityWebApp, the Views have to be compiled as a resources m. In particular, you will have to set the „
Build Action“ property to „Embedded Resource“. This also means that every change in the cshtml of the view will require recompilation.
Another option: move the View to the main SitefinityWebApp, but then you end up with controller and view in different assemblies which feels kind of messy :)
Pls check point 5 in:
www.progress.com/.../create-widgets-mvc
As well as:
www.progress.com/.../create-widgets-in-external-assemblies-mvc
Hope the hint helps
David
Hi David,
Thanks for your prompt response
.
I have followed the same link provided in your response. Also i have changed Build Action property to Embedded Resource. But still no luck :(.
Regarding your another option, i tried that as well and encounter with different issues.
Regards,
Krishan
Hi Krishan,
Ok, then... I can only offer to have a look directly at your Code if you can share it (here or via mail). Actually, I am currently working on a sitefinity project with the same structure (Widgets in separate Assembly) and it works, so there is still hope we‘ll make your case working also ;)
Regards
David
Hi David,
Sharing complete code here or via mail won't be possible because of its size(1.4 GB). Is there any other way around?
Regards,
Krishan