logo
Welcome to our new AbleCommerce forums. As a guest, you may view the information here. To post to this forum, you must have a registered account with us, either as a new user evaluating AbleCommerce or an existing user of the application. For all questions related to the older version of Gold and earlier, please go to AbleCommerce Gold forum. Please use your AbleCommerce username and password to Login. New Registrations are disabled.

Notification

Icon
Error

Options
Go to last post Go to first unread
Joe Payne2  
#1 Posted : Wednesday, March 24, 2021 4:56:17 AM(UTC)
Joe Payne2

Rank: Advanced Member

Groups: HelpDesk, Developers
Joined: 11/9/2018(UTC)
Posts: 564

Thanks: 122 times
Was thanked: 26 time(s) in 25 post(s)
As I migrate a heavily customized Able Gold site to v9, I've hit an interesting wall:

In Gold, I made a complete copy of the /Admin/ area of the site to create a separately-secured section of the site we call the Vendor Portal. A simple change to web.config allows us to restrict this specific area of the site to members of a specific security group. This has worked well for years.

I'm trying to replicate the same thing in V9 with MVC. I started with just creating an area that would render the login page and then send the browser to a default dashboard page. Just like /Admin/ does it. Keeping things simple seemed to be best approach given my current MVC skills.

I've set up a new folder in /Areas/, copied over the bundle configs, area registrations, set up a views/controllers/models folder etc. Then removed the stuff I didn't need and renamed namespaces to eliminate duplicate classes. I even copied the /Views/Shared/ folder and eventually figured out I needed the /Views/_ViewStart.cshtml and /Views/Web.Config files.

All of this works so far, with one exception. I can hit http://website/vendorportal/login and the login page renders. If I authenticate, it then redirects to http://website/vendorportal but throws an error. I get an HTTP 403.14 FORBIDDEN error.

I feel like I've missed a default route somehow, or something hard-coded is going on. Based on my MVC routes below, shouldn't http://website/vendorportal/ be routing to the Index action on the DashboardController? I don't understand why I'm getting 403 FORBIDDEN. Unless somehow there's a permissions change I have missed?

Code:

        public override void RegisterArea(AreaRegistrationContext context) 
        {
            // VENDOR PORTAL LOGIN ROUTE
            context.MapRoute(
                "VendorPortal_login",
                "VendorPortal/Login",
                new { controller = "User", action = "Login", id = UrlParameter.Optional },
                new[] { "AbleCommerce.Areas.VendorPortal.Controllers" }
            );

            // DEFAULT ROUTE
            context.MapRoute(
                "VendorPortal_default",
                "VendorPortal/{controller}/{action}/{id}",
                new { controller = "Dashboard", action = "Index", id = UrlParameter.Optional },
                new[] { "AbleCommerce.Areas.VendorPortal.Controllers" }
            );
            
            RegisterBundles();
        }


Wanna join the discussion?! Login to your AbleCommerce Forums forum account. New Registrations are disabled.

Joe Payne2  
#2 Posted : Wednesday, March 24, 2021 5:09:12 AM(UTC)
Joe Payne2

Rank: Advanced Member

Groups: HelpDesk, Developers
Joined: 11/9/2018(UTC)
Posts: 564

Thanks: 122 times
Was thanked: 26 time(s) in 25 post(s)
AHA! Figured it out. And it was weird.

Not only did I have an area registered as /Areas/VendorPortal/, I also had a folder in the website called /VendorPortal/. It was a leftover from some earlier testing.

By default, MVC routing will not supersede a path that physically exists. Since I had an actual folder /VendorPortal/, routing was ignoring my /Areas/VendorPortal/.

Once I removed the /VendorPortal/ folder from the website, my default route kicks in properly.
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.