Umbraco Controller. Routing. Why I have 404 error for all actions?
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?
Umbraco Controller. Routing. Why I have 404 error for all actions?
I have custom controller like this:
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
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?
Hi Vyacheslav,
You can try and use a full path instead like this:
Then you should be able to call it from [hostname]/umbraco/backoffice/partnerClient/firstClient
If you still have issues, you might want to read the documentation for "Attribute routing with IVirtualPageController" here: https://docs.umbraco.com/umbraco-cms/reference/routing/custom-routes#custom-routes-within-the-umbraco-pipeline
is working on a reply...