I am unable to keep both routing rules working using
Url.Action("action", "Controller") without adding new { Area = "" } in the link.
Is this possible? Please help.
I am unable to keep both routing rules working using
Url.Action("action", "Controller") without adding new { Area = "" } in the link.
Is this possible? Please help.
Copyright © 2021 Jogjafile Inc.
-> Yes, It is possible.We can using area in the route values wen generating URLs using 'Url.Action'
-> Define Default Route in your RouteConfig.cs file :-
-> Define Area-specific Routes :- Define routes for each area in the AreaRegistration class for the area, for example :-
-> Generate URL without Specifiying Area :- Now, when you use Url.Action to generate URLs for controller/action within the default area.and this will generate URL :- /Home/Index
-> Generate URL for Actio in area :- To generate Ul for action within area that time specify the area name.and URL :- /MyArea/SomeController/Index
-> follow this code, you can maintain routing for both default and area-specific controllers/actions without need to specify the area explicitly when generating URLs for default controllers/actions.