Search code examples
c#asp.net-mvc

What problems will I face if I force the use of keywords like "public" and "private" in ASP.NET MVC Area names?


I'd like to name one of my ASP.NET MVC 4.0 Areas "Public". When I add a new Area and names it "Public" Visual Studio instead gives me the name "_Public" - obviously protecting me from using a C# keyword for the Area. The name would be used both in the namespace and as a part of the class name of PublicController. I'd prefer that my public-facing URL didn't contain any underscores, so I've done a rename back to "Public" and so far it seems to work just fine - my Index-page is rendering fine.

Is there any reason I shouldn't go with "Public" without the underscore as the area name? What problems will I face in the future, if any?


Solution

  • No Problem, It's generally a best practice to avoid reserved keyword. For now, there is no constraint from MVC side.

    It'll not create any problem in future for sure. In case you require advance routing please refer following link

    MVC custom routing with validation

    Hope helps