The document discusses ASP.NET MVC, which uses the Model-View-Controller architecture. It abandons the page-based approach of Web Forms in favor of MVC. The model represents core data and logic, views transform models into visual representations, and controllers coordinate between models and views by handling user input and passing results. Routing matches URL patterns to controllers and actions to handle requests.
Download as PPTX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
39 views
MVC 4 INTRODUCTION Lecture 01
The document discusses ASP.NET MVC, which uses the Model-View-Controller architecture. It abandons the page-based approach of Web Forms in favor of MVC. The model represents core data and logic, views transform models into visual representations, and controllers coordinate between models and views by handling user input and passing results. Routing matches URL patterns to controllers and actions to handle requests.
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 13
ENTERPRISE APPLICATION
DEVELOPMENT
ASP.NET MVC
Resource Person: Noor ullah khan
Email: [email protected] ASP.NET MVC Microsoft was quick to spot the growing need in the ASP.NET developer community for something different than the page-based Web Forms approach, and the company released the first version of ASP.NET MVC in 2008. Representing a total departure from the Web Forms approach, ASP.NET MVC abandons the page-based architecture completely, relying on the Model-View-Controller (MVC) architecture instead. THE MODEL-VIEW-CONTROLLER ARCHITECTURE The Model-View-Controller pattern is an architectural pattern that encourages strict isolation between the individual parts of an application. This isolation is better known as separation of concerns, or, in more general terms, loose coupling. Development Individual components do not directly depend on other components, which means that they can be more easily developed in isolation. Components can also be readily replaced or substituted, preventing complications in one component from affecting the development of other components with which it may interact. TESTABILITY Loose coupling of components allows test implementations to stand in for production components. This makes it easier to, say, avoid making calls to a database, by replacing the component that makes database calls with one that simply returns static data. The ability for components to be easily swapped with mock representations greatly facilitates the testing process, which can drastically increase the reliability of the system over time. MAINTENANCE
Isolated component logic means that changes are
typically isolated to a small number of componentsoften just one. Since the risk of change generally correlates to the scope of the change, modifying fewer components is a good thing! THE MODEL The model represents core business logic and data. Models encapsulate the properties and behavior of a domain entity and expose properties that describe the entity. For example, the Auction class represents the concept of an auction in the application and may expose properties such as Title and Current Bid, as well as exposing behavior in the form of methods such as Bid(). THE VIEW The view is responsible for transforming a model or models into a visual representation. In web applications, this most often means generating HTML to be rendered in the users browser, although views can manifest in many forms. For instance, the same model might be visualized in HTML, PDF, XML, or perhaps even in a spreadsheet. Following separation of concerns, views should concentrate only on displaying data and should not contain any business logic themselvesthe business logic stays in the model, which should provide the view with everything it needs. THE CONTROLLER The controller, as the name implies, controls the application logic and acts as the coordinator between the view and the model. Controllers receive input from users via the view, then work with the model to perform specific actions, passing the results back to the view. RUNNING THE APPLICATION . Once your project is created, feel free to hit F5 to execute your ASP.NET MVC website and watch it render in your browser. ROUTING All ASP.NET MVC traffic starts out like any other website traffic: with a request to a URL. This means that, despite the fact that it is not mentioned anywhere in the name,the ASP.NET Routing framework is at the core of every ASP.NET MVC request.
In simple terms, ASP.NET routing is just a pattern-matching system.
At startup, the application registers one or more patterns with the frameworks route table to tell the routing system what to do with any requests that match those patterns. When the routing engine receives a request at runtime, it matches that requests URL against the URL patterns registered with it. When the routing engine finds a matching pattern in its route table, it forwards the request to the appropriate handler for that request. Otherwise, when the requests URL does not match any of the registered route patterns, the routing engine indicates that it could not figure out how to handle the request by returning a 404 HTTP status code. URL REQUEST AND ROUTING DIAGRAM CONFIGURING ROUTES ASP.NET MVC routes are responsible for determining which controller method (otherwise known as a controller action) to execute for a given URL. They consist of the following properties: Unique name A name may be used as a specific reference to a given route URL pattern A simple pattern syntax that parses matching URLs into meaningful segments Defaults An optional set of default values for the segments defined in the URL pattern Constraints A set of constraints to apply against the URL pattern to more narrowly define the URLs that it matches ROUTING EXAMPLE The default ASP.NET MVC project templates add a generic route that uses the following URL convention to break the URL for a given request into three named segments, wrapped with brackets ({}): controller, action, and id: {controller}/{action}/{id}
ASP.NET MVC Fundamentals : Step-by-Step Instructions for Building Web Applications with ASP.NET 8, Integrating SQLite for Robust Data Handling, and Utilizing Entity Framework
Building Modern Web Applications with ASP.NET Core Blazor: Learn how to use Blazor to create powerful, responsive, and engaging web applications (English Edition)
ASP.NET MVC Fundamentals : Step-by-Step Instructions for Building Web Applications with ASP.NET 8, Integrating SQLite for Robust Data Handling, and Utilizing Entity Framework
Building Modern Web Applications with ASP.NET Core Blazor: Learn how to use Blazor to create powerful, responsive, and engaging web applications (English Edition)