If you want to enable routing in C# MVC, you have to do the following steps. Note: this only applies to MVC version 5 or above. Open your RouteConfig.cs file under App_Start folder in your MVC root project.
Add the following code after the IngoreRoute section.
The above code will enable the MVC Attribute Routes mapping. If you do not apply above code, it will just ignore the attribute routing.
The next part is to set the attribute routing in your MVC controller.
For example, I have a page named ForgotPassword and I want to add a hyphen for SEO friendly URL page, so the URL that can be accepted will be forgot-password. In order to fix it, I can use the route prefix and placed it above my ForgotPasswordController class as below.
You can see the screenshot of example of the RoutePrefix including the sample of how to overwrite the routeprefix if needed.