MVC widgets - Front- & Back-End Development - Front- & Back-End Development - Progress Community
 Front- & Back-End Development

MVC widgets

  • MVC widgets
  • HI all. I am implementing a custom login widget on MVC.  There is a Logout() method inside the UserController. Then I have a header widget, that is part of a sitefinity module. So for instance I want to call from custom module widget my Logout() method. I have tried to use @Html.ActionLink("logout", "Logout", "User" ) but nothing works.  

    Could you please recommend me how to implement such logic.

    Best regards, Andrew

    Hello Andrew,

    I tested this on my side and I managed to redirect to the Logout() action in the controller using @Html.ActionLink("LinkText", "YourActionName") 

    Here is the controller I used on my side:

    using System;
    using System.ComponentModel;
    using System.Linq;
    using System.Web.Mvc;
    using Telerik.Sitefinity.Mvc;
    using SitefinityWebApp.Mvc.Models;
    namespace SitefinityWebApp.Mvc.Controllers
        [ControllerToolboxItem(Name = "LogoutMVCWidget", Title = "LogoutMVCWidget", SectionName = "MvcWidgets"), Telerik.Sitefinity.Web.UI.ControlDesign.ControlDesigner(typeof(SitefinityWebApp.WidgetDesigners.LogoutMVCWidget.LogoutMVCWidgetDesigner))]
        public class LogoutMVCWidgetController : Controller
            /// <summary>
            /// Gets or sets the message.
            /// </summary>
            [Category("String Properties")]
            public string Message get; set;
            /// <summary>
            /// This is the default Action.
            /// </summary>
            public ActionResult Index()
                var model = new LogoutMVCWidgetModel();
                if (string.IsNullOrEmpty(this.Message))
                    model.Message = "Hello, World!";
                    model.Message = this.Message;
                return View("Default", model);
            /// <summary>
            /// This is the default Action.
            /// </summary>
            public ActionResult Logout()
                var model = new LogoutMVCWidgetModel();
                model.Message = "Here is the Logout() action from the controller";
                return View("Default", model);

    And here is the markup of the controller's view where I added the @Html.ActionLink():

    @model SitefinityWebApp.Mvc.Models.LogoutMVCWidgetModel
    @Html.ActionLink("Click here to logout", "Logout")

    I am also sending attached a short video for your convenience demonstrating the results.

    Can you please try to use the same approach on your side?

    Sabrie Nedzhip
    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