Routing is nothing but simply your mvc url. What mean is that simply your url. for example some developers using some kinds of prefix name cls with class name and also given method name as their own idea. These kinds of things definitely end user will not understand for rectify those problem we have to use routing in mvc.
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action= "Index", id = UrlParameter.Optional }
);
Description:
Routes is route collection and MapRoute is method name for routes. MapRoute have three arguments like name, url and defaults. Here name is key name and its unique.
IgnoreRoute methods used to do not allow user to invoke such kind of file .axd
routes.MapRoute(
name: "Home",
url: "",
defaults: new { controller = "Employee", action= "Index", id = UrlParameter.Optional }
);
Here when I build the application it will automatically call Index view with in Employee Controller. Please remember one thing default name unique will come last why because if you set default name as first none of your matching url will not execute.
Post your comments / questions
Recent Article
- How to create custom 404 error page in Django?
- Requested setting INSTALLED_APPS, but settings are not configured. You must either define..
- ValueError:All arrays must be of the same length - Python
- Check hostname requires server hostname - SOLVED
- How to restrict access to the page Access only for logged user in Django
- Migration admin.0001_initial is applied before its dependency admin.0001_initial on database default
- Add or change a related_name argument to the definition for 'auth.User.groups' or 'DriverUser.groups'. -Django ERROR
- Addition of two numbers in django python
Related Article