In general, use a SurfaceController when you need an UmbracoContext (the thing that tells you what page you are on). You might want that, for example, if there is a form on the page and you want to know what page the user posted the form from.
Use an ApiController if you are calling the service from something external to the website (e.g., via an app). I believe in this case you don't have an UmbracoContext (which makes sense, since you aren't "on" a page).
Surface Controllers URL, keep getting 404
Hi I created the following SurfaceController:
According to the doc (https://our.umbraco.org/Documentation/Reference/Mvc/surface-controllers) I should be able to call this via: http://localhost:12429/umbraco/surface/NgakNgakAction/AjaxTest but I keep getting a 404.
I also saw that there are APIControllers (https://our.umbraco.org/documentation/Reference/WebApi/).
Which type should I use for fron end ajax calls?
Thanks!
Whooops! Figured it out! Needed to change from [HttpPost] to [HttpGet].
The question whether to use a SurfaceController or an APIController remains.
Thanks
In general, use a SurfaceController when you need an UmbracoContext (the thing that tells you what page you are on). You might want that, for example, if there is a form on the page and you want to know what page the user posted the form from.
Use an ApiController if you are calling the service from something external to the website (e.g., via an app). I believe in this case you don't have an UmbracoContext (which makes sense, since you aren't "on" a page).
Okay great, got it! Thanks
is working on a reply...