Search Your Dot Net Topic

Tuesday 9 January 2018

Routing in Asp.Net MVC


In this article you will come to know about Asp.NET MVC Routing.

What is Routing ?
Why Routing required ?
WebForm vs MVC
Advantage of Routing
How to configure Routing?
How Routing Work?


What is Routing?
In general sense Routing meaning is way. Asp.net MVC Routing doing the same thing it show the way to a request. Basically routing is used for handling HTTP request and search match action method then execute the same.

It constructs outgoing URLs that correspond to controller actions.

Routing means which map request with Controller’s Action Method.
Routing is match incoming request, and we can call Routing is pattern matching which manages the incoming request. It match request with Route Table.


Why Routing Required or Important?
As per MVC, Model View Controller are main independent components.
These three components work individually.

Any incoming request handle by Controller. MVC not directly mapped with physically UI output file. That is mapped by controller at run time and route table.

Asp Net MVC Routing Training Institute Borivali East, Asp.Net Training Institute Kandivali  East
Asp Net MVC Routing Training Institute Borivali East















For more information about Route Table and Route Collection

  
  
WebForm vs MVC:

In WebForm technology url directly attached physical file.


In MVC url not directly attached with any physical file its attached with Action Method of Controller.

As you can see in above URL:
www.myshop.com  : Domain Name
plastic : Controller Name
index :  Action Method Name

Asp.Net MVC Routing Training Institute Borivali West, Asp.Net Training in Dahisar
Asp Net MVC Routing Training Institute Borivali West




















As you can see in above URL:
www.myshop.com  : Domain Name
bottle : Controller Name
plastic :  Action Method Name
100 : 100 is a id or Paramter passed to action method

Asp Net MVC Routing Training Institute Kandivali West , Dot Net Training Institute in Malad West
Asp Net MVC Routing Training Institute Kandivali West















Advantages of Routing:
1. Routing is very friendly & helpful for SEO (search engine optimization).
2. All URL not directly map with physical file.
3. More powerful securities than WebForm.



How to configure Routing?
Configure / setting routing is very simple. As you see in your solution explorer there is App_Start folder, in this folder you can see there is RouteConfig.cs file.

Asp Net MVC Routing Training Institute Kandivali East , AspNet CSharp Training Institute in Andheri
Asp Net MVC Routing Training Institute Kandivali East















  public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller =”<Your Default Controller Name>“, action = "<Your Default Action Name>", id = UrlParameter.Optional }
            );
        }


NOTE: What is App_Start folder in Asp.Net MVC?
 App_Start folder has been introduced in MVC4. This folder having
 all setting related files as you can see in image.
1. BundleConfig.cs
2. FilterConfig.cs
3. IdentityConfig.cs
4. RouteConfig.cs
5. Start.Auth.cs

How Routing Work?
Asp Net MVC Routing Training Institute Malad East, Asp.Net Training Institute in Goregoan East
Asp Net MVC Routing Training Institute Malad East

Happy Coding...

I provide personalized training through home tuition or online on Dot Net (.Net) , Asp.Net [WebForm / MVC], WCF, WPF, WebService, Windows Application, Console Application.

If you liked this post, I’d be very grateful if you’d help it spread by emailing it to a friend, or sharing it on Twitter or Facebook or Google+.

Leave a comment that starts a conversation.

Thank you!

1 comment:

  1. It is amazing and wonderful to visit your site. Thanks for sharing this information; this is useful to me...
    Read more about .net training in gurgaon

    ReplyDelete