Closed ste22g closed 7 years ago
Hi, and sorry for the delayed reply. It's not clear what your question is exactly, since routing and security are two separate and unrelated concerns.
I did notice that you have your route misconfigured, though. The route class only supports one optional route parameter and it must be the right-most parameter. It will work for incoming routes, but it won't be able to work out what to do when generating the URL if you don't supply all of the parameters. To fix this, you should have multiple routes...
routes.MapRoute(
name: "RouteB",
url: "CtrB/{action}/{target}/{id}/{sectionId}/{itemId}",
defaults: new { controller = "CtrB", itemId = UrlParameter.Optional }
);
routes.MapRoute(
name: "RouteB-2",
url: "CtrB/{action}/{target}/{id}",
defaults: new { controller = "CtrB", Id = UrlParameter.Optional }
);
routes.MapRoute(
name: "RouteB-3",
url: "CtrB/{action}",
defaults: new { controller = "CtrB", action = "Index" }
);
My guess is the misconfigured routing is taking you to the wrong action method, so the security in turn is not getting executed.
Thank's a lot.
ste22g
Hi, using a custom route with security trimming enabled, the menu lines are always displayed regardless of by the attribute set in the controller method security. Where the custom route is not used it all works correctly. In the code below the Menu "A" working properly while the "B" and "C" menus are always displayed. The AuthorizeIsAdminLevel attribute inherits from AuthorizeAttribute and is the same used in all controllers.
config:
sitemap:
route:
controllers:
Thank you as of now who can help me.
ste22g