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();
}
|
|
|
|
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.
|
|
|
|
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.
Important Information:
The AbleCommerce Forums uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close