Copied to clipboard

Flag this post as spam?

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


  • Alexander Carpenter 19 posts 141 karma points
    Jul 28, 2018 @ 03:40
    Alexander Carpenter
    0

    Add Controller to Visual Studio Cloud Setup

    I have followed the recommended setup for Visual Studio with Umbraco cloud. I am now trying to add controllers but the option isn't available. I can create my own mvc project and add controllers easily, but I am trying to follow their recommended setup and it doesn't have the option anywhere. Is there any easy way to fix this?

  • Søren Kottal 712 posts 4570 karma points MVP 6x c-trib
    Jul 30, 2018 @ 20:56
    Søren Kottal
    1

    Hi Alexander

    Did you follow this approach? https://our.umbraco.com/documentation/Umbraco-Cloud/Set-Up/Working-With-Visual-Studio/

    Then you should be able to add controllers to your *.Core project. Remember to build and commit the dll :)

  • Alexander Carpenter 19 posts 141 karma points
    Jul 30, 2018 @ 22:59
    Alexander Carpenter
    0

    Yes, that is what I followed. But when I right click on the controller folder to add a controller it isn't an option.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jul 31, 2018 @ 04:15
    Jan Skovgaard
    0

    Hi Alexander

    Can you share a screendump of what it looks like?

    /Jan

  • Alexander Carpenter 19 posts 141 karma points
    Jul 31, 2018 @ 17:48
    Alexander Carpenter
    0

    Yes. Should be attached. Cloud VS Solution

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jul 31, 2018 @ 18:09
    Jan Skovgaard
    0

    Hi Alexander

    Sorry if I'm missing something but to me it appears that you have the "Class" option available under "Add" and then it's the last options to the left bottom in the screendump?

    When you select the "Class" then you can name it "MyCustomController.cs" - It's not like you will get a specific item in visual studio called "Controller" if that is what you're wondering? :) (And once again sorry if I totally misunderstand you!)

    /Jan

  • Alexander Carpenter 19 posts 141 karma points
    Jul 31, 2018 @ 18:27
    Alexander Carpenter
    0

    enter image description here

    I do though in all of the training for the surface controllers. I tried just recreating the code but it wouldn't ever compile properly, but I may have typed something improperly. I can do the surface controllers and have them working, but only locally. The recommended cloud setup is where I am having the issue. Confused both on how to get it working and why the recommended setup is so different than the training for surface controllers in general.

  • Nik 1614 posts 7260 karma points MVP 7x c-trib
    Jul 31, 2018 @ 20:53
    Nik
    1

    Hi Alexander,

    The difference between a cloud set up and a general Umbraco set up isn't a huge amount. However there are a few differences.

    1) The Umbraco Cloud files are part of a Web Site project rather than a Web Application project. This is the first thing to note, its also part of the reason why with the Umbraco Cloud project you aught to have the .Core project (as per the guidelines).

    2) The .Core project is a Dll project, as such you don't see the same menu options you see in Visual Studio when right clicking on the "controllers" folder compared to the same folder in a MVC / Web Application project. It is predominantly just Visual Studio not being as helpful.

    As for you issue of not being able to get the surface controller working, that could be for a variety of reasons.

    a) as you say, you could have typed something wrong.

    b) It could be that a reference / using statement is missing

    c) You've not uploaded the latest build of core project when you've pushed to cloud.

    However, you've not said what the error you are getting with regards to the Surface Controller so I can only speculate at this point. There could be other reasons.

    Fundamentally, however, creating a surface controller for Cloud or for Umbraco is the same, you just create the file in a different Visual Studio project.

    Nik

  • Alexander Carpenter 19 posts 141 karma points
    Jul 31, 2018 @ 21:15
    Alexander Carpenter
    0

    So if I just add a cs class and the same code as I would for the controller then it should work in the same way that adding a controller directly would?

  • Nik 1614 posts 7260 karma points MVP 7x c-trib
    Aug 01, 2018 @ 07:25
    Nik
    0

    Hi Alexander,

    Yes, in theory it should be the same code wise. I've had no issues relating to code (unless you forget to make your class public which I've done a few times and wondered why it wouldn't work!)

    Cheers

    Nik

  • David Zweben 268 posts 754 karma points
    Aug 05, 2018 @ 18:41
    David Zweben
    0

    I have the same problem, the MVC templates don't show up for me in Visual Studio when using a project set up following Umbraco's recommended approach with separate .Web and a .Core projects. Everything still works, but I have to create the files manually and can't take advantage of templates. If anyone has a solution for this, that would be great.

Please Sign in or register to post replies

Write your reply to:

Draft