+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Deploying an existing ASP.NET MVC Web Application as MVC Widgets in Sitefinity

Deploying an existing ASP.NET MVC Web Application as MVC Widgets in Sitefinity

8 posts, 0 answered
  1. Samir Vaidya
    Samir Vaidya avatar
    261 posts
    Registered:
    05 Feb 2005
    02 Jul 2013
    Link to this post
    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.
  2. Stanislav Velikov
    Stanislav Velikov avatar
    1113 posts
    Registered:
    22 Sep 2016
    04 Jul 2013
    Link to this post
    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
    Refer to this documentation for sample widget created with MVC.

    Additionally this documentation sample implements MVC widget that utilizes Sitefinity API which can also be of help.

    Regards,
    Stanislav Velikov
    Telerik
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Samir Vaidya
    Samir Vaidya avatar
    261 posts
    Registered:
    05 Feb 2005
    07 Jul 2013 in reply to Stanislav Velikov
    Link to this post
    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.
  4. Stanislav Velikov
    Stanislav Velikov avatar
    1113 posts
    Registered:
    22 Sep 2016
    11 Jul 2013
    Link to this post
    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
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Samir Vaidya
    Samir Vaidya avatar
    261 posts
    Registered:
    05 Feb 2005
    11 Jul 2013 in reply to Stanislav Velikov
    Link to this post
    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.
  6. Stefani Tacheva
    Stefani Tacheva avatar
    718 posts
    Registered:
    09 Sep 2016
    16 Jul 2013
    Link to this post
    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

    If developing MVC widgets inside sitefinity project it is best to use Area folders to encapsulate the MVC components as the separation of controllers and models from the view will not be very convenient.

    Regards,
    Stefani Tacheva
    Telerik
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  7. Balanjaneyulu
    Balanjaneyulu avatar
    35 posts
    Registered:
    11 Feb 2016
    21 Mar in reply to Stanislav Velikov
    Link to this post

    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









  8. Stanislav Velikov
    Stanislav Velikov avatar
    1113 posts
    Registered:
    22 Sep 2016
    24 Mar
    Link to this post
    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.CorticonResponseDesigner))]
    2. The designer must inherit from ControlDesignerBase
    public class CorticonResponseDesigner : ControlDesignerBase

    Refer to the attached sample widget + designer for reference, compare with the designer and controller at your end to spot the cause of the problem.

    Regards,
    Stanislav Velikov
    Telerik
     
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
8 posts, 0 answered