Consider the following sidebar:
If I press the sub menu item All solutions
under the menu item Solutions
, I would see a grid somewhat like this one:
The url for this grid is https://something.com/Solutions
. Now imagine that I wanted to go into the menu item Partners
and sub menu item Active
, the url would be https://something.com/Partners/active
.
I'm using a simple Html.ActionLink
like so:
Html.ActionLink("- Active", "Active", "Partners", null, new { @class = "filter-button" })
PROBLEM
Navigating the user to the url https://something.com/Partners/active
using the Html.ActionLink
the way I do, this should work, but it doesn't. Instead of redirecting me to the active partners view, the application redirects me back to https://something.com/Solutions
(exactly where I came from) but with this url: https://something.com/Solutions?undefined=undefined
.
If I press the Active
sub menu item in the menu item Partners
once more, the url hanges to https://something.com/Solutions?undefined=undefined&undefined=undefined
and this goes on forever.
I have no idea why this occurs nor do I have any solution.
PARTNERS/ACTIVE
public ActionResult Active()
{
using(var db = new DatabaseContext())
{
var partners = db.Partners.Where(x => x.Active).ToList();
return View(partners);
}
}
ROUTE DEFINITIONS
routes.MapRoute(
name: "ControllerIdActionId",
url: "{controller}/{id}/{action}/{id2}",
defaults: new { id2 = UrlParameter.Optional }
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
routes.MapRoute(
name: "Solutions",
url: "{controller}/{id}/{action}/",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
UPDATE
After reviewing the route definitions, I noticed that the route definition Solutions
was never used. I've now removed that route definition so the route definitions look like this:
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
routes.MapRoute(
name: "ControllerIdActionId",
url: "{controller}/{id}/{action}/{id2}",
defaults: new { id2 = UrlParameter.Optional }
);
This had made no difference though. I tried changing the two routes around so the ControllerIdActionId
route would be registered before the Default
, but this has no effect either.