Removing action route #57035
Unanswered
DotCat1985
asked this question in
Q&A
Replies: 1 comment 1 reply
-
|
Use this code and see if it works |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I developed the following class for removing any action route in
Startup.cs:where the method
RemoveRoute()removes a route given byrouteNamefromControllerEndpointRouteBuilderExtensionsobject of ASP.NET Core framework.So, I created my Startup class as following:
where:
GetOrCreateDataSource()returns thedataSourceobject, which is a part of ASP.NET Core framework and contains the action routes I want to removeRouteManipulator.RemoveRoute(dataSource, "Login");removes a route with the name "Login" from thedataSourceobjectWhen I run the code above, the following line code of
RouteManipulator.RemoveRoute():var routes = routesFieldValue as List<object>;returns always
nulleven ifroutesFieldValuehas value. Maybe, I should writevar routes = routesFieldValue as List<ConventionalRouteEntry>;, butConventionalRouteEntryis an internal class (see the source code here).Perhaps, how can I solve my issue?
Beta Was this translation helpful? Give feedback.
All reactions