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?
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!)
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.
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.
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?
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!)
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.
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?
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 :)Yes, that is what I followed. But when I right click on the controller folder to add a controller it isn't an option.
Hi Alexander
Can you share a screendump of what it looks like?
/Jan
Yes. Should be attached.
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
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.
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
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?
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
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.
is working on a reply...