Copied to clipboard

Flag this post as spam?

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


  • Ryan Groene 9 posts 29 karma points
    Apr 13, 2012 @ 20:03
    Ryan Groene
    0

    Surface controller not appearing

    Hello, I'm new here. I just recently installed Umbraco, and I've been looking through how everything works. I've had success with most of it, but I'm having trouble implementing a surface controller. From the tutorials I read, it seems that it can be done as a package or simply by placing it into a controllers directory, but I guess I must be missing something. I added a "Controllers" directory to the root folder, and added a class for the controller. But when I try to create a macro of type ChildAction, it does not come up. Here is the code I used for my controller:

    using System;

    using System.Collections.Generic;

    using System.Linq;

    using System.Web;

    using System.Web.Mvc;

    using Umbraco.Cms.Web.Context;

    using Umbraco.Cms.Web;

    using Umbraco.Cms.Web.Surface;

     

    namespace MyProject.Controllers

    {

    // I tried it with or without this data annotation

        [Surface("6d818fa0-fc6a-46a0-a33b-b454ffab7d80")]

    public class TestSurfaceController : SurfaceController

    {

            //Constructor

            public TestSurfaceController(IRoutableRequestContext requestContext)

                : base(requestContext)

            {

            }

    [ChildActionOnly]

    public PartialViewResult processFormData(Contact contact)

    {

    if (contact == null)

    {

    contact = new Contact();

    }

    return PartialView("processFormData", contact);

    }

     

    }

    public class Contact

    {

    public string FirstName;

    public string LastName;

    public string Email;

    }

    }

  • Morten Bock 1867 posts 2140 karma points MVP 2x admin c-trib
    Apr 13, 2012 @ 20:16
    Morten Bock
    0

    Did you add the following to your AssemblyInfo.cs file?

    using Umbraco.Cms.Web;
    [assembly: AssemblyContainsPlugins]

    That is the way Umbraco knows that is should look for plugins in the dll.

  • Ryan Groene 9 posts 29 karma points
    Apr 13, 2012 @ 20:53
    Ryan Groene
    0

    Hey, thanks for the response!

    The tutorial I read said that it was possible to do it without having to create a plug-in. I could try the plug-in method, but, initially, this method seemed simpler. I shouldn't need the [assembly: AssemblyContainsPlugins] if I'm not doing it as a plug-in, should I? If so, does that mean that the controller needs to be compiled? Also, where is the AssemblyInfo.cs file supposed to be in the project?

  • Morten Bock 1867 posts 2140 karma points MVP 2x admin c-trib
    Apr 13, 2012 @ 23:18
    Morten Bock
    0

    As I understand it, you always need to include that attribute. The AssemblyInfo.cs file should be on the Properties folder in your project. 

    I don't know if it is possible to crate a controller without compiling it. Also I don't know why you would want to?

  • Ryan Groene 9 posts 29 karma points
    Apr 14, 2012 @ 00:19
    Ryan Groene
    0

    I think I might as well figure out how to make a plug-in--I'll probably have to know how to do that at some point anyway. But, the tutorial that I was following was http://shazwazza.com/post/Umbraco-Jupiter-Plugins-Part-5-Surface-Controllers.aspx, which suggests that you do not actually need to use a plug-in to make a surface controller (and a couple other tutorials, I think, said similar things). I did create an AssemblyInfo.cs file in the Properties directory of the main Umbraco project, but that didn't help. I guess what I meant by not compiling the controller was not compiling it as a separate dll, which, as I understand, is what you need to do to create a plug-in.

  • Paul Stoker 39 posts 72 karma points c-trib
    Apr 25, 2012 @ 16:59
    Paul Stoker
    0

    I'm having the same issue with the Child Action being missing from the drop down, I've followed the steps a number of times with and without attributes. Can anyone post a basic VS solution so I can be sure I haven't missed anything?

    There's a JavaScript error on the macros page in Back Office which I hope isn't affecting the Child Actions being pulled in?!

  • Danny 49 posts 104 karma points
    May 10, 2012 @ 16:29
    Danny
    0

    I as well am having issues with this.  I'm trying to create a simple controller that will return some JSON to an AJAX call (via the non plug-in approach) and it doesn't even appear to be finding the controller in the controllers folder.  It is just looking in the /Umbraco path.  

  • Henri Toivonen 77 posts 111 karma points
    May 29, 2012 @ 13:50
    Henri Toivonen
    0

    Dont forget, controllers have to be compiled. I just make a new project in VS, which I then reference. It is not enough that you have a folder called controllers.

    You don't have to make a plugin for it nor add anything to assemblyinfo.

Please Sign in or register to post replies

Write your reply to:

Draft