Copied to clipboard

Flag this post as spam?

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


  • Remi Martel 32 posts 104 karma points
    Jun 27, 2018 @ 15:23
    Remi Martel
    0

    External Url to Controller

    I don't understand how custom routes in Umbraco work. How can I access a controller's action through a URL from another website? Basically, I have another website for customer support from which employees should be able to access a customer's account with the customer's email only. The thing is I can't get the various tokens and the email to a controller.

    The url I am testing with looks like this: host/login/externallogin/0000/0000/0000/[email protected]

    Here is my custom route :

    RouteTable.Routes.MapRoute(
                name: "ExternalLoginRoute",
                url: "login/{action}/{customerKey}/{sessionKey}/{token}/{email}",
                defaults: new
                {
                    controller = "CustomRoutingHandlerController",
                    customerKey = UrlParameter.Optional,
                    sessionKey = UrlParameter.Optional,
                    token = UrlParameter.Optional,
                    email = UrlParameter.Optional
                });
    

    Here the controller I made, I commented out almost everything to at least reach a breakpoint at the beginning of the controller

    public class CustomRoutingHandlerController : Controller
    {
        // GET: CustomRoutingHandler
        public ActionResult ExternalLogin(string customerKey, string sessionKey, string token, string email)
        {
        //BREAKPOINT NOT BEING REACHED HERE
            // Controller Code (removed)
            return View();
        }
    }
    
  • kows 81 posts 151 karma points c-trib
    Jun 28, 2018 @ 09:14
    kows
    0

    Could you try:

    RouteTable.Routes.MapRoute(
            name: "ExternalLoginRoute",
            url: "login/{action}/{customerKey}/{sessionKey}/{token}/{email}",
            defaults: new
            {
                controller = "CustomRoutingHandler"
            });
    

    ?

    might be you also have to update "umbracoReservedPaths".

  • Remi Martel 32 posts 104 karma points
    Jul 04, 2018 @ 17:00
    Remi Martel
    0

    I changed the controller name (can't believe I left 'controller' at the end!), but it still doesn't work. I added the reserved path for '~/login' and all it changed it that instead of my 404 page, I get 'No physical template file was found for template externallogin' (my URL being 'host/login/externallogin/...')

    Also, I don;t get how the handler works when using 'RouteTable.Routes.MapUmbracoRoute' instead of 'RouteTable.Routes.MapRoute'

Please Sign in or register to post replies

Write your reply to:

Draft