hello
in the below code i have two areas and am using conventional routing in MVC my my qustion do i always should add the name of the
the area to the pattern as below

hello
in the below code i have two areas and am using conventional routing in MVC my my qustion do i always should add the name of the
the area to the pattern as below

Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Tuhin PaulRank #7 · 71.9K reputationPosted Oct 18, 2024, 12:57 PM EDT
You don't have to add the area name to the pattern in your conventional routing. it's often a good idea to do so, especially for clarity and consistency. When you look at the route pattern, it's immediately clear which area the route belongs to. This makes it easier to understand and debug your application. If all your routes have the area name in the pattern, it provides a consistent approach, making your code easier to maintain. If you have routes with the same names in different areas, adding the area name to the pattern ensures that there are no naming conflicts.
1. Including Area Name in the Pattern:
app.MapAreaControllerRoute( name: "blog", areaName: "Blog", pattern: "blog/{controller}/{action}/{id?}" );Pros: Clearer, consistent, prevents potential conflicts.
Cons: Slightly more verbose.
2. Not Including Area Name in the Pattern:
app.MapAreaControllerRoute( name: "blog", areaName: "Blog", pattern: "{controller}/{action}/{id?}" );Pros: Less verbose.
Cons: Less clear about the route's area, potential conflicts if similar routes exist in other areas.
mina shaker157 reputationPosted Oct 19, 2024, 10:42 AM EDT
@Tuhin Paul but when i did it like below code as you can see the pattern is the same no area spacifaied this where the conflicts come into place correct?
app.MapAreaControllerRoute( name : "blog", areaName : "Blog", pattern : "{controller}/{action}/{id?}" ); app.MapAreaControllerRoute( name: "Zebra", areaName: "Zebra", pattern: "{controller}/{action}/{id?}" );