Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Tomasz 10 posts 101 karma points
    Jan 12, 2016 @ 20:41
    Tomasz
    0

    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:

    No physical template file was found for template Register
    
       [Exception: No physical template file was found for template Register]
           Umbraco.Web.Mvc.RenderMvcController.CurrentTemplate(T model) +212
           lambda_method(Closure , ControllerBase , Object[] ) +94
           System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +229
           System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +35
           System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState) +39
           System.Web.Mvc.Async.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult) +67
           System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +42
           System.Web.Mvc.Async.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d() +72
           System.Web.Mvc.Async.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +386
           System.Web.Mvc.Async.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +386
           System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +42
           System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInvokeAction>b__1c() +38
           System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +186
           System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +38
           System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +29
           System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +65
           System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +53
           System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +36
           System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +38
           System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +44
           System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +65
           System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +38
           System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +399
           System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +137
    

    I have no idea what's going on :( I noticed that when I change action part of routing for e.g.

     defaults: new { controller = "MemberzController", action = "Registerab", id = UrlParameter.Optional }
    

    I am getting error

    No physical template file was found for template Registerab
    
  • Ian 178 posts 752 karma points
    Jan 12, 2016 @ 21:32
    Ian
    1

    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

  • Tomasz 10 posts 101 karma points
    Jan 12, 2016 @ 22:20
    Tomasz
    1

    Hi Ian, thanks for response. I changed it like You said but with no success :(

        RouteTable.Routes.MapRoute(
           name: "MemberRegister",
           url: "Member/{action}/{id}",
           defaults: new { controller = "MemberzController", action = "Register", id = UrlParameter.Optional }
           );
    

    I tried several combinations, with only {action}, other actions, but still nothing :(

  • Ian 178 posts 752 karma points
    Jan 12, 2016 @ 22:51
    Ian
    100

    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?

  • Tomasz 10 posts 101 karma points
    Jan 12, 2016 @ 23:13
    Tomasz
    0

    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:

    RouteTable.Routes.MapRoute(
        name: "MemberRegister",
        url: "Member/Register",
        defaults: new { controller = "Memberz", action = "Register"}
    );
    
Please Sign in or register to post replies

Write your reply to:

Draft