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 use if else statement in c++?
- How to use godaddy domain name with another godaddy hosting account?
- Restore of database 'DATABASE' failed. (Microsoft.SqlServer.Management.RelationalEngineTasks)
- How to programmatically modifying the AppSetting value in web.config using c#?
- TypeError [ERR_INVALID_CALLBACK]: Callback must be a function. Received undefined
- How to calculate the age from jQuery ui datepicker using c#?
- How to calculate days difference between two dates in c#?
- Changing date format in jQuery ui datepicker
Related Article