Copied to clipboard

Flag this post as spam?

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


  • Saied 349 posts 674 karma points
    Aug 21, 2015 @ 02:20
    Saied
    0

    Using MVC Controllers with Umbraco

    I created an empty ASP.NET empty web application and installed Umbraco through nuget. I also added bootstrap to it. Since I installed an empty project, I don't get the controller intellisense (for example, when you right click on the controllers folder in MVC, it gives you the option to add a controller), so is their a preferred method to incorporating the controllers in the project? Is it do to it manually? or should is it better to have it in a separate project?

  • Samira 113 posts 452 karma points
    Aug 24, 2015 @ 13:03
    Samira
    0

    Hi,

    Because u choose blank ASP.NET application project in visual studio 2013 and controller is the part of MVC application

    Choose MVC application than your controller will be show when u right click on controller folder

    /Grazitti

  • Lars-Erik Aabech 350 posts 1102 karma points MVP 8x c-trib
    Aug 24, 2015 @ 13:31
    Lars-Erik Aabech
    0

    But then again, you shouldn't use regular MVC controllers inheriting System.Web.Mvc.Controller in an Umbraco project.

    You should probably use an Umbraco.Web.Mvc.SurfaceController, and in that case the right-click thingy is useless.

    Just make a folder called Controllers, add a regular class and manually inherit it from SurfaceController. It will get URLs as described here:

    https://our.umbraco.org/documentation/reference/routing/surface-controllers

  • James 251 posts 1169 karma points
    Aug 24, 2015 @ 21:20
    James
    0

    Hi Mate,

    When you create you project at the start click (Visual Studio 2012) choose .NET Framework 4.5.1 and select Asp.NET MVC 4 Project.

    Install Umbraco over the top of that. Once finished, you will be able to right click the controller folder and create your controller.

    You can use standard MVC controllers but its better to use SurfaceController or UmbracoApiController. You can read up why on the documentation section of this site.

    Hope that helps!

Please Sign in or register to post replies

Write your reply to:

Draft