Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Steven McLintock 12 posts 56 karma points
    Jul 11, 2014 @ 09:59
    Steven McLintock
    0

    How to call ActionResult in Umbraco template?

    I'm using Umbraco 7 to let a member login and update their profile.

    I have created the login form using a SurfaceController, which will send the user to "/update-driver", however on this page I cannot create a controller to check if the user is authenticated and fetch their profile details.

    I have read that you need to use a RenderController for this type of action in Umbraco? I have created the following controller in my project but I can't get the page to recognise it.

    Thanks for any help!

    UpdateDriverController:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Mvc;
    using Umbraco.Web.Models;
    
    namespace UmbracoCMS.Controllers
    {
        public class UpdateDriverController : Umbraco.Web.Mvc.RenderMvcController
        {
            public override ActionResult Index(RenderModel model)
            {
                // Check if the user is logged in
                //if (!User.Identity.IsAuthenticated)
                //{
                    // Send the user to the login page
                    Redirect("/login");
                //}
    
                return base.Index(model);
            }
        }
    }
    

    Template

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @{
        Layout = "BootstrapDefaultcshtml.cshtml";
    }
    
    @Html.Partial("MemberDriverUpdate", new UmbracoCMS.Models.MemberDriverModel())
    

    Partial View

    @using UmbracoCMS.Controllers
    @model UmbracoCMS.Models.MemberDriverModel
    
    @Html.ValidationSummary()
    
    @using (Html.BeginUmbracoForm<MemberDriverSurfaceController>("Update"))
    {
        /*** Form Fields ***/
    }
    
  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies