Controllers Different between Umbraco 7 and Umbraco 7.4.3
Hi, Folks!!
I'm trying to create a form using MVC (I'm following some tutorials on the same matter) and when I link the action created in the controller within the view that the Umbraco will manage, I use the policy:
@using My_Umbraco.Controllers
(Where My_Umbraco is the name of my project)
It generated an error indicating that it can not understand this project name ... What I am unable to understand is that the tutorials I'm following always refer to version 7 and this project name usage works perfectly. Since I am using the 7.4.3 version, it shows some screen differences between the version 7 of the tutorials I'm questioning myself if this way of indicating the drivers created by us is modified.
Does anyone know tell me if I am correct? Is it necessary to inform the Umbraco where my controllers? Is there any configuration that is required to be made to the Umbraco 7.4.3 understand the name of my project during the execution?
Below show the screens programmed with the result that the Umbraco returns me ...
Please, I'm already several days trying to solve this issue and I am not finding the solution Not one forum, blog or Umbraco documentation.
Have you included the controller file into the Visual Studio project? Check in the solution explorer - if it's a grey outline then right click and "Include in project".
I've just been through and created the same setup you have and it worked perfectly :( Sorry to add to the despair!
Sorry to ask but - you are building the solution each time, right? The Controllers and models are built into dlls - when using Umbraco it can be confusing what's needs to be built and compiled and what can be changed at runtime (e.g. Views). The error you're showing is Umbraco saying it can't find the Controller (or the method on it). Usually this is a typo - though I'm convinced what you have is right.
If you are building try a clean and rebuild and a restart of VS - never underestimate the bugginess of VS! Stick a break point on the ShowForm method to see if it is hitting it (though I'm sure it isn't).
Failing that the only piece of the puzzle you haven't posted is the Contact Form partial view. Can you confirm that under /Views/Partials/ you have ContactForm.cshtml (I'd expect a different error though here - I just don't think we're hitting the Controller)?
To rule out some VS funniness try a fresh example - I've written a tutorial which is MVC but for member login but the code download should just "work" - perhaps try it with a fresh copy of Umbraco?!
Steve, than you so much for your help... You are right. After rebuild the solution, Umbraco found the controller.
Nik, after work as the solution given by Steve, I tested both forms of creation of Controller: your way to create and how I had created. Both ways worked. Thank you very much for your answer.
I do have the same problem, but in my case, there is no existing namespace declaration. I am still having this problem until now.
As what I have observed on some developers, whenever they create a new class, a namespace declaration would automatically be generated same as the name of the project.
The problem that I am now facing is that I don't know the namespace associated in this project. And even if I am going to create a namespace declaration and rebuild the project, it still won't work.
I donĀ“t know if you find the solution to your problem, but look the picture, I read that you done a Controller, but not extends a SurfaceController.
Look the line:
public class ContactSurfaceController
change to:
public class ContactSurfaceController: SurfaceController
Controllers Different between Umbraco 7 and Umbraco 7.4.3
Hi, Folks!!
I'm trying to create a form using MVC (I'm following some tutorials on the same matter) and when I link the action created in the controller within the view that the Umbraco will manage, I use the policy:
(Where My_Umbraco is the name of my project)
It generated an error indicating that it can not understand this project name ... What I am unable to understand is that the tutorials I'm following always refer to version 7 and this project name usage works perfectly. Since I am using the 7.4.3 version, it shows some screen differences between the version 7 of the tutorials I'm questioning myself if this way of indicating the drivers created by us is modified.
Does anyone know tell me if I am correct? Is it necessary to inform the Umbraco where my controllers? Is there any configuration that is required to be made to the Umbraco 7.4.3 understand the name of my project during the execution? Below show the screens programmed with the result that the Umbraco returns me ... Please, I'm already several days trying to solve this issue and I am not finding the solution Not one forum, blog or Umbraco documentation.
Hi,
Have you included the controller file into the Visual Studio project? Check in the solution explorer - if it's a grey outline then right click and "Include in project".
Steve
Complementing the information:
In these tutorials I'm following, when the tutorial executor creates a new template, the Umbraco puts the following information:
In Umbraco 7.4.3, when we create a new template, the information entered by him change:
It may be that the issue that takes Umbraco to reject the @using command with the name of my project?
HI, Steve!!
Thanks for your answer. I done the Controller by VS, but I checked and the controllers is include in my project.
Hi,
Is the build action set to Compile?
(Look in the Properties).
Steve
HI,
Just comparing what you have to a working example here.
There is no need to add a @using for the My_Umbraco.Controllers - take that line out of your view.
Steve
Steve,
I done your suggest, but now show me other error.... I am crasy !!!
I change to
But the same error show me.
Do you have other idea to me? (I'm entering the zone of despair :#)
Thank you for your patience with me
Hi,
I've just been through and created the same setup you have and it worked perfectly :( Sorry to add to the despair!
Sorry to ask but - you are building the solution each time, right? The Controllers and models are built into dlls - when using Umbraco it can be confusing what's needs to be built and compiled and what can be changed at runtime (e.g. Views). The error you're showing is Umbraco saying it can't find the Controller (or the method on it). Usually this is a typo - though I'm convinced what you have is right.
If you are building try a clean and rebuild and a restart of VS - never underestimate the bugginess of VS! Stick a break point on the ShowForm method to see if it is hitting it (though I'm sure it isn't).
Failing that the only piece of the puzzle you haven't posted is the Contact Form partial view. Can you confirm that under /Views/Partials/ you have ContactForm.cshtml (I'd expect a different error though here - I just don't think we're hitting the Controller)?
To rule out some VS funniness try a fresh example - I've written a tutorial which is MVC but for member login but the code download should just "work" - perhaps try it with a fresh copy of Umbraco?!
http://siempresolutions.co.uk/blog/UmbracoMembersPart3AFullSolution
Steve
Grr that link should be:
Umbraco Members Full Solution Blog post
I've seen some oddities when creating surface controllers in the past, with no real explanation as to why.
Try changing your controller declaration to:
Then try calling your action with the following:
Steve, than you so much for your help... You are right. After rebuild the solution, Umbraco found the controller.
Nik, after work as the solution given by Steve, I tested both forms of creation of Controller: your way to create and how I had created. Both ways worked. Thank you very much for your answer.
Thanks a both.
No worries!
Happy to help! I found once you've got your first working MVC controller it's much easier in the future to compare and find out what's not working!
I do have the same problem, but in my case, there is no existing namespace declaration. I am still having this problem until now.
As what I have observed on some developers, whenever they create a new class, a namespace declaration would automatically be generated same as the name of the project.
The problem that I am now facing is that I don't know the namespace associated in this project. And even if I am going to create a namespace declaration and rebuild the project, it still won't work.
I hope you can help me with this. Thanks.
Martin, I hope you is all right!!
I donĀ“t know if you find the solution to your problem, but look the picture, I read that you done a Controller, but not extends a SurfaceController. Look the line:
public class ContactSurfaceController
change to:
public class ContactSurfaceController: SurfaceController
is working on a reply...