Deploying an existing ASP.NET MVC Web Application as MVC Widgets in Sitefinity
I have an existing ASP.NET MVC Web Application project that I have developed that I would like to deploy as ASP.NET MVC Widgets into Sitefinity.
I have seen tutorials on how to develop and deploy ASP.NET MVC Widgets using Sitefinity Thunder, however, there does not seem to be any guidance or documentation on how to deploy such Widgets into Sitefinity from an existing ASP.NET MVC Web Application that already contains a set of controllers and views.
Can anyone please point me to any documentation or guidance on how to accomplish this?
Thanks.
Hello,
Sitefinity MVC widgets in their structure doesn`t differ from standard asp.net mvc MVC except that there is an additional attribute for the controller name, ControllerToolboxItem which register the control as MVC widget in sitefinity with Name, Title in particular section from the available widgets to be placed on pages.
[ControllerToolboxItem(Name =
"Events"
, Title =
"Events"
, SectionName =
"MvcWidgets"
)]
public
class
EventsController : Controller
Is there a way to deploy MVC Widgets to the Sitefinity Toolbox without decorating them with these attributes in a manner similar to how ASP.NET User Controls are deployed to the Sitefinity Toolbox using Advanced settings-->Toolbox and specifying the virtual path to the User Control?
I want to develop an ASP.NET MVC Web Application that is not referencing any of the Telerik assemblies in order to retain loose coupling of my application from the Sitefinity platform.
Please advise.
Thanks.
Hi,
Yes it is possible for MVC widgets register the
Control CLR Type or Virtual Path Telerik.Sitefinity.Mvc.Proxy.MvcControllerProxy
Controller CLR type SitefinityWebApp.Mvc.Controllers.MvcWidgetController (CLR type of the controller)
Name MvcWidget (name of the class, without the "Controller" string)
Title MvcWidget
here is a screenshot.
Regards,
Stanislav Velikov
Telerik
What if I am building separate Controllers, Views and Models in a COMPLETELY separate assembly? For example, what I am building an entire ASP.NET MVC 4 web application that is compiled into its own assembly? How do I register my individual Views and Controllers into the Sitefinity Toolbox in that instance?
Thanks.
Hello,
Full encapsulation is not possible (the whole widgets to be present in separate dll) at least the View will have to be part of the sitefinity project. The model and controller classes can be part of another project and its .dll registered in Sitefinity will serve as the type from which the view will take its model.
@model AssemblyProject.Mvc.Models.MyWidgetModel
Hi STANISLAV VELIKOV,
I was trying to create self-installing MVC sitifinity
widget. I got few issue while registering the widget automatically.
I have CorticonResponseController widget developed in MVC
pattern. I also have response widget designer for this widget. In My control
class, I have decorated my class with ControolerTollBox item.
I could successfully register the widget however I was
facing issue while getting the designer view.
The issue is
Server Error in '/' Application.
Sequence contains no elements
Description: An unhandled exception occurred during the
execution of the current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: Sequence contains no elements
Source Error:
An
unhandled exception was generated during the execution of the current web
request. Information regarding the origin and location of the exception can
be identified using the exception stack trace below.
Stack Trace:
[InvalidOperationException:
Sequence contains no elements]
System.Linq.Enumerable.First(IEnumerable`1
source) +264
Telerik.Sitefinity.Web.UI.ControlDesign.Singleton.GetDesigner(ControlData
ctrlData) +288
Telerik.Sitefinity.Web.UI.ControlDesign.ControlDesignerFactory.GetDesigner(ControlData
ctrlData) +36
Telerik.Sitefinity.Web.UI.PropertyEditor.PrepareControlDesigner(ControlData
ctrlData) +58
Telerik.Sitefinity.Web.UI.PropertyEditor.InitializeControls(GenericContainer
dialogContainer) +1249
Telerik.Sitefinity.Web.UI.SimpleView.CreateChildControls() +106
Telerik.Sitefinity.Web.UI.DialogBase.CreateChildControls() +38
System.Web.UI.Control.EnsureChildControls() +92
System.Web.UI.WebControls.CompositeControl.get_Controls() +16
Telerik.Sitefinity.Web.UI.PropertyEditor.OnInit(EventArgs e) +81
System.Web.UI.Control.InitRecursive(Control namingContainer) +139
System.Web.UI.Control.AddedControl(Control
control, Int32 index) +185
System.Web.UI.ControlCollection.Add(Control child) +86
Telerik.Sitefinity.Web.DialogRouteHandler.InitializeContent(Page
handler, RequestContext requestContext) +410
Telerik.Sitefinity.Web.RouteHandlerBase.Handler_Load(Object sender,
EventArgs e) +294
System.Web.UI.Control.OnLoad(EventArgs e)
+95
System.Web.UI.Control.LoadRecursive() +59
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +678
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET
Version:4.6.1055.0
Hello,
The issue occurring with loading the designer for this MVC based widget is that the designer can`t be found.
When adding designer there are 2 requirements, I have attached a widget with a functional designer refer to CorticonResponseWidget+Designer.zip.
1. The designer must be linked to the controller via a decoration as you have mentioned
[ControllerToolboxItem(Name =
"CorticonResponse"
, Title =
"CorticonResponse"
, SectionName =
"MvcWidgets"
), Telerik.Sitefinity.Web.UI.ControlDesign.ControlDesigner(
typeof
(SitefinityWebApp.WidgetDesigners.CorticonResponse.C
orticonResponseDesigner
))]
public
class
CorticonResponseDesigner : ControlDesignerBase