I have custom controller like this:
using System.Web.Mvc;
using Umbraco.Web.Mvc;
using HttpGetAttribute = System.Web.Mvc.HttpGetAttribute;
using RouteAttribute = System.Web.Mvc.RouteAttribute;
using RoutePrefixAttribute = System.Web.Mvc.RoutePrefixAttribute;
namespace MyProject.Host.Controllers
{
[RoutePrefix("partnerClient")]
public class PartnerClientController : UmbracoController
{
[HttpGet]
[Route("firstClient")]
public ActionResult FirstClient()
{
return View(@"~/Views/Partner/FirstPartnerClientView.cshtml");
}
}
}
I am trying to call action {hostname}/partnerClient/firstClient But I got an error: Page not found No umbraco document matches the URL '/partnerClient/firstClient'.
But when I use UmbracoApiController routing is ok.
using Umbraco.Web.WebApi;
using HttpGetAttribute = System.Web.Http.HttpGetAttribute;
using RouteAttribute = System.Web.Http.RouteAttribute;
using RoutePrefixAttribute = System.Web.Http.RoutePrefixAttribute;
namespace MyProject.Host.Controllers
{
[RoutePrefix("partnerClient")]
public class PartnerClientController : UmbracoApiController
{
[HttpGet]
[Route("firstClient")]
public object FirstClient()
{
return "{test}";
}
}
}
I have to return View for this action and UmbracoApiController doesn't allow it. How I should configure routing for UmbracoController? Or maybe I should use some other way to return some View?
Not sure where you got the idea of using "UmbracoController" from - but you shouldn't :-/
Take a look at https://our.umbraco.com/documentation/Reference/Routing/ - it looks like you should use a RenderMvcController, but look through the docs to be sure.