I have just started learning Umbraco using MVC and find two terms such as UmbracoTemplatePage and SurfaceControllers.
In some of the links i find that all the views are getting inherited from UmbracoTemplatePage and similarly find that all the controllers are inherited from SurfaceController.
Is it essential to do this inheritance in views and controllers for umbraco based development? If yes what are the advantages of using this inheritance for both
UmbracoTemplatePage and SurfaceController?
A surface controller is a bit more powerful than a normal MVC
controller as it knows a lot more about Umbraco, the current page and
other contexts than a regular old ASP.NET MVC controller would not
know.
Normally you would create a partial view by simply using the @model
MyModel syntax. However, inside of Umbraco you will probably want to
have access to the handy properties available on your normal Umbraco
views like the Umbraco helper: @Umbraco and the Umbraco context:
@UmbracoContext
I just did some reading on these two topics and feel that both UmbracoTemplatePage and SurfaceController provide us access to Umbraco features which help us to do complex tasks quickly.
Without using UmbracoTemplatePage and SurfaceController it will be difficult to do such tasks. Is my understanding fine then i have the following tw questions :-
Suppose if i inherit my base layout (Template from UmbracoTemplatePage) even then do i need to inherit my view/partial view from UmbracoTemplatePage which will be rendered in that base layout?
Suppose we have a base controller and that base controller is inherited from SurfaceController i am hoping that all the controllers which are inheriting from base controller will not need to implement SurfaceController. All the features of SurfaceController will be accessible in the controllers inherited from base controller?
Unless you need to provide some interactivity via a form or to expose your data via the API then you can do most of the data finding and looping task right there on the view with RAZOR syntax.
You only need to create surface controllers if you are accessing items not within the scope of the Umbraco model.
Perhaps you should specify what you actually want to do?
What is UmbracoTemplatePage and SurfaceController
Hi All,
I have just started learning Umbraco using MVC and find two terms such as UmbracoTemplatePage and SurfaceControllers.
In some of the links i find that all the views are getting inherited from UmbracoTemplatePage and similarly find that all the controllers are inherited from SurfaceController.
Is it essential to do this inheritance in views and controllers for umbraco based development? If yes what are the advantages of using this inheritance for both UmbracoTemplatePage and SurfaceController?
SurfaceController:
Quote, Warren Buckley:
http://creativewebspecialist.co.uk/2013/07/22/umbraco-mvc-what-on-earth-is-a-surface-controller/
UmbracoTemplatePage :
https://our.umbraco.org/documentation/Reference/Templating/Mvc/partial-views
Hi All,
Thanks for the answer.
I just did some reading on these two topics and feel that both UmbracoTemplatePage and SurfaceController provide us access to Umbraco features which help us to do complex tasks quickly.
Without using UmbracoTemplatePage and SurfaceController it will be difficult to do such tasks. Is my understanding fine then i have the following tw questions :-
Suppose if i inherit my base layout (Template from UmbracoTemplatePage) even then do i need to inherit my view/partial view from UmbracoTemplatePage which will be rendered in that base layout?
Suppose we have a base controller and that base controller is inherited from SurfaceController i am hoping that all the controllers which are inheriting from base controller will not need to implement SurfaceController. All the features of SurfaceController will be accessible in the controllers inherited from base controller?
Please verify.
Hi Naman,
What is problem with BaseController? Why you need a lot of Controllers? Can you tell more what exactly do you want to achieve?
Cheers, Alex
Unless you need to provide some interactivity via a form or to expose your data via the API then you can do most of the data finding and looping task right there on the view with RAZOR syntax.
You only need to create surface controllers if you are accessing items not within the scope of the Umbraco model.
Perhaps you should specify what you actually want to do?
is working on a reply...