No physical template file was found for template ***
Greeting,
I have a problem with making custom controller setup. Following Documentation and forum posts I have these files:
RoutingHandler model:
public class RoutingHandler : ApplicationEventHandler
{
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
RouteTable.Routes.MapRoute(
name: "MemberRegister",
url: "member/register",
defaults: new { controller = "MemberzController", action = "Register", id = UrlParameter.Optional }
);
}
}
MemberzController:
public class MemberzController : Umbraco.Web.Mvc.RenderMvcController
{
public ActionResult Register(RenderModel model)
{
//Do your db stuff here...
return PartialView("~/Views/Partials/Member/Register.cshtml", model);
}
}
And Partial View in /Views/Partials/Member/Register.cshtml.
When I am going to address /member/register I am getting following error:
Hi Tomasz, there are others on here who can probably explain the issue much better than I can but I encountered the exact same problem when I registered a route with no tokens in the 'url' argument, you could modify the route url to member/{action} or member/{action}/{id} and I think your controller should be hit without error. As umbraco auto route several things umbraco api controllers , surface controllers templates and files ending in aspx i came to the conclusion your url pattern clashes with the template route. If anyone else could provide an answer how to register a static route as in your example that would be helpful though
Hi there I just noticed that you are specifying the receiving controller as memberzcontroller and not just memberz i.e the name of the controller minus 'controller' if you make that edit do you have any more luck? What are the errors now?
No physical template file was found for template ***
Greeting, I have a problem with making custom controller setup. Following Documentation and forum posts I have these files:
RoutingHandler model:
MemberzController:
And Partial View in /Views/Partials/Member/Register.cshtml. When I am going to address /member/register I am getting following error:
I have no idea what's going on :( I noticed that when I change action part of routing for e.g.
I am getting error
Hi Tomasz, there are others on here who can probably explain the issue much better than I can but I encountered the exact same problem when I registered a route with no tokens in the 'url' argument, you could modify the route url to member/{action} or member/{action}/{id} and I think your controller should be hit without error. As umbraco auto route several things umbraco api controllers , surface controllers templates and files ending in aspx i came to the conclusion your url pattern clashes with the template route. If anyone else could provide an answer how to register a static route as in your example that would be helpful though
Hi Ian, thanks for response. I changed it like You said but with no success :(
I tried several combinations, with only {action}, other actions, but still nothing :(
Hi there I just noticed that you are specifying the receiving controller as memberzcontroller and not just memberz i.e the name of the controller minus 'controller' if you make that edit do you have any more luck? What are the errors now?
Man, you are great! Like always - simple mistake and many hours wasted... Now it works, even with no tokens/wildcards in url.
Working piece of code:
is working on a reply...