I want to use an Umbraco API controller - and I have found this example on how to get access to an Umbraco API Controller from Razor.
var requestContext = HttpContext.Current.Request.RequestContext;
var urlHelper = new System.Web.Mvc.UrlHelper(requestContext);
var url = urlHelper.GetUmbracoApiService("GetAllProducts", "ProductsApiController");
Umbraco API Controller - use from Template
I want to use an Umbraco API controller - and I have found this example on how to get access to an Umbraco API Controller from Razor.
https://our.umbraco.com/Documentation/Reference/Routing/WebApi/routing
But I can't find any information on what to do next, what Type is url? and how do I make use of it to call the GetAllProducts method?
Thanks in advance for any help to get me in the right direction.
/Thomas
Hi Thomas,
I think a parameter is missing. Try: var url = urlHelper.GetUmbracoApiService("GetAllProducts", "ProductsApiController",null);
Graham
Thanks for reply, I ended up using a different approach with javascript, vue.js and axios and got it all to work from clientside only.
I think it would be nice to make an Umbraco tutorial on using Umbraco API Controllers from a template with either vue.js or angular as mvvm framework.
To be able to use javascript from Umbraco template, it's nessecary to understand and use ASP.Net MVC sections.
is working on a reply...