The default rendering engine for Umbraco routes requests through RenderMvcController with an IPublishedContent object as the model view. This provides a pretty simple means of basic pages rigged up with managed content but you can extend this behavior by creating custom controllers. Umbraco refers to this technique of creating custom controllers as hijacking, though really it is just a matter of creating a controller where MVC would normally look.
To create a controller for our Home view we just create a controller called HomeController. To hook it up to Umbraco’s content API you will need to inherit from RenderMvcController and override the Index method as shown below:
publicclassHomeController : Umbraco.Web.Mvc.RenderMvcController
{
publicoverrideActionResult Index(RenderModel model)
{
//Do some stuff here, then return the base methodreturnbase.Index(model);
}
}
Creating controllers to handle forms and actions is a little more involved as you have to create what Umbraco calls asurface controller. This is a controller like any other but one that is derived from the Umbraco SurfaceControllerclass. These controllers can be implemented as a normal part of your MVC project (“locally declared” in Umbraco-speak) or implemented as a plug-in for shipping as part of a package.
If you want to include your own custom MVC routes then you will have to override the OnApplicationStartedmethod. This can be done by creating your own custom global.asax file that inherits from Umbraco.Web.UmbracoApplication.
MVC 4 with Umbraco 6
hi
I have created the solution in visual studio 2010,
but my problem is am unable to add Controller in controller , its giving some version error Please find the Screen shot
Please can anybody help on this
Thanks
Vijayadurga P
Can you provide more details? Such as an error message or screen shot?
I would recommend checking out this excellent guide from Ben Morris... http://www.ben-morris.com/using-umbraco-6-to-create-an-asp-net-mvc-4-web-applicatio to hopefully spot anything you may or may not have done.
From the link...
Creating a custom controller
The default rendering engine for Umbraco routes requests through RenderMvcController with an IPublishedContent object as the model view. This provides a pretty simple means of basic pages rigged up with managed content but you can extend this behavior by creating custom controllers. Umbraco refers to this technique of creating custom controllers as hijacking, though really it is just a matter of creating a controller where MVC would normally look.
To create a controller for our Home view we just create a controller called HomeController. To hook it up to Umbraco’s content API you will need to inherit from RenderMvcController and override the Index method as shown below:
Creating controllers to handle forms and actions is a little more involved as you have to create what Umbraco calls asurface controller. This is a controller like any other but one that is derived from the Umbraco SurfaceControllerclass. These controllers can be implemented as a normal part of your MVC project (“locally declared” in Umbraco-speak) or implemented as a plug-in for shipping as part of a package.
If you want to include your own custom MVC routes then you will have to override the OnApplicationStartedmethod. This can be done by creating your own custom global.asax file that inherits from Umbraco.Web.UmbracoApplication.
You also need to change the umbraco config (correct me if i am wrong there) from WebForms to MVC :)
Thanks for the reply
i changed it in config..
Did that work? and no problem :)
no its not working ,, actually we have folllowed your steps . i mean what u mentioned in your blog ...
based on that we created solution and copied files from Zip except App_code, bin folders, and changed the UmbracoSetting.config
Db Set up for Umbraoco :-) ....
My blog post does work :). So what error are you getting now? Charlie :)
hi
i have tried with u r examples but am getting this error . i dont what i was doing mistake here .. its ot working at all :-( please help me on this
since one week i am fighting with this :-(
Hi Vijayadurga ,
We can only help you if you post more details. So again what is the error you getting?
I think this error happens as there is a conflict in the version of MVC that uGoLive uses and the version of MVC used in 2010.
Try this:
1. Take a copy of the uGoLive dll in the bin folder
2. Delete the uGoLive dll
I couldn't see the screenshot so I am only assuming that it is the same error.
Hope this helps.
Thanks.. I have checked in my bin but there are 3 dlls are there
1.Our.Umbraco.uGoLive.47x.dll
2.Our.Umbraco.uGoLive.Checks.dll
3.Our.Umbraco.uGoLive.dll
these three dlls i need to delete ?
If it's only VS that tells you it's unable to create a controller than you just have to create a class in the controllers folder.
You can than derive it from the Umbraco controllers.
I have the same error when i try to create a controller in VS, but with just creating a class it works.
yes exactly .. but now we i overcome that problem..:-)
Did you get the issue fixed? What worked for you in the end?
yes.. :-).. i am adding the controllers like(see the screen shots) in this way..
in added controller we are inherting Surfacecontroller(see the screen shot)
r u able to see the screen shots ?
Sadly i can't see any Screenshot. Would also like to know how you did it.
is working on a reply...