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 : Tuesday, May 18, 2021 1:58:15 PM(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)
Completely my fault, but wanted to share the experience for other devs new to MVC...

I've been making extensive admin customizations to a 9.0.4 install that I'm converting from Gold R12. All of this work is done in the /Areas/Admin/ part of the folder structure.

One of my customizations provides a way for the admin user to upload documents and assign to a specific store user account. They love it for keeping tax exempt certificates on file for all of their customers. Part of this customization is the upload routine which handles receiving the file via the browser and saving it to a specified path in the admin. I was using the path /Admin/People/Users/UserDocuments/ as the document path.

Here's the problem: As I was testing the upload code I just migrated to MVC, I happened to go back to the main admin dashboard. Except now it's not rendering. Just keeps throwing a Forbidden 403.14 error and I have no idea why. I didn't change any MVC routes. I didn't change anything in global.asax. I spent well over an hour carefully reviewing each and every code change to make sure I didn't break MVC routing. Yet, still the admin dashboard would not render.

And ONLY the dashboard. Every other admin page worked just fine. Now I'm completely lost.

I did some googling and found a mention of a similar scenario. The issue was the dev had a folder called 'Something' and a controller called 'Something'. So IIS throws the HTTP request to the physical folder first, before checking for an MVC route to a controller. I thought "You know, that sounds sorta familiar. Could I have an /Admin/ folder somehow??"

Sure enough, I check the site folders and I had a folder /Admin/People/Users/UserDocuments/. Sound familiar?

When I was testing my document upload routine, my code auto-created the complete folder structure starting with /Admin/ before saving the uploaded file. Normally a solid dev practice to folder. Except I failed to change the physical path in my code to align with the v9 /Areas/ folder structure. So my code just created /Admin/People/......... and moved on.

And that's how you blow 90 minutes of your life on your own code being too smart.....

Moral of the story: Do not create a physical folder name in the site that also matches the name of an area defined in /Areas/. IIS (by default) will route the request to the physical path first without checking MVC area routes first.

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

Users browsing this topic
Guest (2)
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.