New at Umbraco, I've been following the Umbraco TV tutorials and I was trying to create a login-controller, but in my project this is what happens:
And the "Web User Control" creates an .aspx with:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="LoginController.ascx.cs" Inherits="Controllers_LoginController" %>
You definitely don't want to see Web User Control in the right-click menu (that's what causing the ascx and ascx.cs files).
Is this project set up as a Web Application in VS? If not, delete and make sure it is (and set up an empty ASP.NET project when you get the prompts. Then install Umbraco via Nuget).
When the project was stopped the problem persisted.
And though completely deleting the project and starting fresh from a nuget package (Not version 8 though because it gives me errors) does allow me to add controllers.
My concern is that the project that didn't allow me to add a Controller was the one I'd downloaded from the cloud/server using GitKraken.
Is there a potential solution that doesn't involve having to start from scratch?
Can you confirm if this is Umbraco V8 or Umbraco V7 you are running?
Something to note, just because you are missing an option from the context menu doesn't mean you can't create the right sort of file. It might just mean you don't get some of the boilerplate code.
A controller is "just" a class file, but there if you don't have the option to add a class you can "cheat" the program a bit. If you select "JavaScript File" and then call it "MyController.cs" it will create a cs file.
In this file, delete everything it autopopulates it with (if it does) and there you have a blank C# class file ready to go :-)
For example you could add the following code (note, you'd need to add the correct namespaces)
public class MyController : SurfaceController
{
}
This would give you a controller called "MyController" :-)
Typically we use PM in Visual Studio.
Might be a start over, however, it is pretty easy to copy and paste work already done.
Your best bet is to do the following. Works every time. We don't use the Git pull, we usually use the Nuget Package manager.
Install .Net 4.7.2 if you have not done so
Open Visual Studio
Create new project
Choose a Web project and an ASP.NET Web Application(.NET Framework), of course using 4.7.2
Choose and 'Empty' application from the Project Templates dialog that pops up in Visual Studio and leave all the "Core references" unselected.
All the MVC stuff will come in with the PM pull. Click 'OK'
In the Visual Studio hover over 'Tools' from the toolbar, hover over Nuget Package Manager > choose Package Manager Console
In the Package Manager Console, enter after the PM >
Install-Package UmbracoCms -Version 8.0.0
This will pull everything from the Package Manager from NuGet. It will install all MVC Dlls, framework stuff, and all of Umbraco.
After that, you will run your project and continue onward. If there is not a Controllers folder, you will just have to add a new Folder to the project called "Controllers" and then within that folder you would be able to create a new controller file.
Can't add a controller?
New at Umbraco, I've been following the Umbraco TV tutorials and I was trying to create a login-controller, but in my project this is what happens:
And the "Web User Control" creates an .aspx with: <%@ Control Language="C#" AutoEventWireup="true" CodeFile="LoginController.ascx.cs" Inherits="Controllers_LoginController" %>
What should I do?
By the looks of it you are trying to add a controller while running the solution in debugging mode. Click this button
and try to add controller again.
@Mario, if that is the case, than yes Marius is correct.
Was this your issue?
You definitely don't want to see Web User Control in the right-click menu (that's what causing the ascx and ascx.cs files).
Is this project set up as a Web Application in VS? If not, delete and make sure it is (and set up an empty ASP.NET project when you get the prompts. Then install Umbraco via Nuget).
Hope that helps!
When the project was stopped the problem persisted.
And though completely deleting the project and starting fresh from a nuget package (Not version 8 though because it gives me errors) does allow me to add controllers.
My concern is that the project that didn't allow me to add a Controller was the one I'd downloaded from the cloud/server using GitKraken.
Is there a potential solution that doesn't involve having to start from scratch?
Hi Mario,
sounds like it's an Umbraco Cloud project.
Can you confirm if this is Umbraco V8 or Umbraco V7 you are running?
Something to note, just because you are missing an option from the context menu doesn't mean you can't create the right sort of file. It might just mean you don't get some of the boilerplate code.
A controller is "just" a class file, but there if you don't have the option to add a class you can "cheat" the program a bit. If you select "JavaScript File" and then call it "MyController.cs" it will create a cs file.
In this file, delete everything it autopopulates it with (if it does) and there you have a blank C# class file ready to go :-)
For example you could add the following code (note, you'd need to add the correct namespaces)
This would give you a controller called "MyController" :-)
Might help,
Thanks
Nik
@Mario,
Typically we use PM in Visual Studio. Might be a start over, however, it is pretty easy to copy and paste work already done.
Your best bet is to do the following. Works every time. We don't use the Git pull, we usually use the Nuget Package manager.
Install .Net 4.7.2 if you have not done so
All the MVC stuff will come in with the PM pull. Click 'OK'
Install-Package UmbracoCms -Version 8.0.0
After that, you will run your project and continue onward. If there is not a Controllers folder, you will just have to add a new Folder to the project called "Controllers" and then within that folder you would be able to create a new controller file.
Let me know if you have any questions.
is working on a reply...