Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Naman 20 posts 101 karma points
    Mar 24, 2016 @ 10:12
    Naman
    0

    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?

  • Dennis Adolfi 1082 posts 6446 karma points MVP 5x c-trib
    Mar 24, 2016 @ 10:39
    Dennis Adolfi
    0

    SurfaceController:

    Quote, Warren Buckley:

    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.

    http://creativewebspecialist.co.uk/2013/07/22/umbraco-mvc-what-on-earth-is-a-surface-controller/

    UmbracoTemplatePage :

    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

    https://our.umbraco.org/documentation/Reference/Templating/Mvc/partial-views

  • Naman 20 posts 101 karma points
    Mar 24, 2016 @ 11:31
    Naman
    0

    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 :-

    1. 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?

    2. 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.

  • Alex Skrypnyk 6132 posts 23951 karma points MVP 7x admin c-trib
    Mar 25, 2016 @ 13:37
    Alex Skrypnyk
    0

    Hi Naman,

    1. Yes
    2. Yes

    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

  • Streety 358 posts 568 karma points
    Mar 25, 2016 @ 15:10
    Streety
    0

    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?

Please Sign in or register to post replies

Write your reply to:

Draft