ASP. net mvc Tutorial: understanding models, views, and controllers (3)

Source: Internet
Author: User

On the contrary, when building ASP. NET MVC Applications In ASP. net mvc applications, a URL corresponds to a controller action rather than a page file on the hard disk.

In traditional ASP. net and ASP applications, browser requests are mapped to the page, in ASP. net MVC applications, browser requests are mapped to Controller behavior, Asp.. NET applications are content-centric. On the contrary, Asp.. Net MVC applications are centered on application logic.

Understanding URL Routing

Browser requests are mapped to Controller behavior through a URL routing feature of ASP. net mvc. url routing routes inbound requests to Controller behavior.

URL routing uses a route table to process inbound requests. When your application is started for the first time, this route table is configured in global. in the asax file, the default MVC global. the content of the asax file is shown in Listing 1.

Listing 1 Global. asax

Public Class GlobalApplication

   Inherits System.Web.HttpApplication

     Shared Sub RegisterRoutes(ByVal routes As RouteCollection)

        routes.IgnoreRoute("{resource}.axd/{*pathInfo}")

        ' MapRoute takes the following parameters, in order:

        ' (1) Route name

        ' (2) URL with parameters

        ' (3) Parameter defaults

        routes.MapRoute( _

          "Default", _

          "{controller}/{action}/{id}", _

          New With {.controller = "Home", .action = "Index", .id = ""} _

        )

     End Sub

     Sub Application_Start()

        RegisterRoutes(RouteTable.Routes)

     End Sub

End Class

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.