ASP .NET MVC

1,226 views

Published on

Published in: Technology
  • Be the first to comment

ASP .NET MVC

  1. 1. ASP .NET Model View Controller<br />University “Al.I.Cuza”, Iasi<br />Faculty of Computer Science<br />EldorinaAlergus<br />AndreeaJipa<br />
  2. 2. The Model-View-Controller (MVC) architectural pattern separates an application into three main components: <br /><ul><li>the model
  3. 3. the view
  4. 4. the controller. </li></li></ul><li><ul><li>Models. Model objects are the parts of the application that implement the logic for the application's data domain. Often, model objects retrieve and store model state in a database. For example, a Product object might retrieve information from a database, operate on it, and then write updated information back to a Products table in SQL Server</li></li></ul><li><ul><li>Views are the components that display the application's user interface (UI). Typically, this UI is created from the model data. An example would be an edit view of a Products table that displays text boxes, drop-down lists, and check boxes based on the current state of a Products object.</li></ul>In ASP.NET the view is the set of web pages presented by a web application.<br />
  5. 5. <ul><li>Controllers The controller is the object that allows the manipulation of the view. Usually many applications implement Model-Controller tiers that contain the business logic along with the necessary code to manipulate a user interface. In an ASP.NET application the controller is implicitly represented by the code-behind or the server side code that generates the HTML presented to the user.</li></li></ul><li>A basic diagram that would help us understand the specific parts that implement the MVC architecture in an ASP.NET application is presented below: <br />
  6. 6. How does ASP .NET MVC looks like?<br />
  7. 7. ASP .NET MVC project specific directory architecture<br /><ul><li>App_Data is the physical store for data.
  8. 8. Content folder keeps files such as scripts, CSS, images and so on.
  9. 9. Controllers folder is the location for controllers. The MVC requires the names of all controller to end with Controller.
  10. 10. Models stores classes that handle application business logic.
  11. 11. Scripts is the folder for script files. By default, it contains AJAX script files and the JQuery library.
  12. 12. Views is the recommended location for views. It my contain .aspx, .ascx, .master and other files that are related to rendering views.</li></li></ul><li>Advantages of an MVC-Based Web Application<br /><ul><li>It makes it easier to manage complexity by dividing an application into the model, the view, and the controller.
  13. 13. It does not use view state or server-based forms. This makes the MVC framework ideal for developers who want full control over the behavior of an application.
  14. 14. It uses a Front Controller pattern that processes Web application requests through a single controller. This enables you to design an application that supports a rich routing infrastructure.</li></li></ul><li>Advantages of an MVC-Based Web Application<br /><ul><li>It provides better support for test-driven development (TDD).</li></ul>TDD is an evolutionary approach to development which combines test-first development where you write a test before you write just enough production code to fulfill that test and refactoring.<br /><ul><li>It works well for Web applications that are supported by large teams of developers and Web designers who need a high degree of control over the application behavior</li></li></ul><li>Possible problems with ASP .NET MVC<br />Problems may appear when testing the application. Especially the GUI and the code-behind classes in a page controller based model, is very difficult to test because the only way to test something like a button click&apos;s code-behind event handler is to click the button itself! This means that if we put more and more code in code-behind classes (which inevitably becomes the case in large web applications with lots of UI controls), we will not be able to run unit tests on the UI code. <br />
  15. 15. Possible problems with ASP .NET MVC<br />So the only way to test the application would be to manually test the GUI. The page controller based design does not support unit testing, and we would not be able to use automated unit testing tools such as NUnit, MBUnit and so on (which we can easily use to test the other layers such as BLL and DAL).<br />
  16. 16. Resources<br />http://www.asp.net/mvc/learn/<br />Download<br />http://www.microsoft.com/downloads/details.aspx?FamilyID=53289097-73ce-43bf-b6a6-35e00103cb4b&displaylang=en<br />

×