Copied to clipboard

Flag this post as spam?

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


  • JacobMarcussen 6 posts 76 karma points
    1 day ago
    JacobMarcussen
    0

    Custom endpoint/route handling

    I have problem with my custom routing in Umbraco 13. I have a Umbraco 7 site running where my custom routes is defined like so:

    routes.MapUmbracoRoute(
          "ProductProductType",
          "produkter/{producttype}",
          new
          {
            controller = "Product",
            action = "ProductType",
            page = ProductType.Course
          },
          new UmbracoVirtualNodeByIdRouteHandler(1360)
        );
    

    I've tried setting it up multible ways in Umbraco 13. Both with Custom middleware and by following: https://docs.umbraco.com/umbraco-cms/reference/routing/custom-routes

    But in every scenario i end up getting this error: No UmbracoRouteValues feature was found in the HttpContext

    This is Controller from Umbraco 7:

    public ActionResult ProductType(ProductTypeModel model, string producttype, ProductType page)
    {
      try
      {
        mTimer.Start();
        model.ProductType = producttype == null ? string.Empty : producttype.ToLower();
        model.Page = page;
        model.ProductUrl = this.Request.Url.ToString();
        var preparedModel = mProductControllerService.PrepareProductTypeModel(model);
        if (preparedModel.Success)
        {
          if (!string.IsNullOrWhiteSpace(model.RedirectToUrl))
            return new RedirectResult(model.RedirectToUrl, true);
          return View("Productpage", preparedModel.Value);
        }
    
        mSharedHelperService.RedirectToErrorPage(preparedModel);
        return null;
      }
      finally
      {
        mTimer.Stop();
        //Debug.WriteLine($"ProductController ProductType ({mTimer.ElapsedMilliseconds} milliseconds))");
      }
    }
    

    I hope my problem makes sense.

    Thanks!

Please Sign in or register to post replies

Write your reply to:

Draft