Your SlideShare is downloading. ×
0
ASP.NET MVC Fundamental
ASP.NET MVC Fundamental
ASP.NET MVC Fundamental
ASP.NET MVC Fundamental
ASP.NET MVC Fundamental
ASP.NET MVC Fundamental
ASP.NET MVC Fundamental
ASP.NET MVC Fundamental
ASP.NET MVC Fundamental
ASP.NET MVC Fundamental
ASP.NET MVC Fundamental
ASP.NET MVC Fundamental
ASP.NET MVC Fundamental
ASP.NET MVC Fundamental
ASP.NET MVC Fundamental
ASP.NET MVC Fundamental
ASP.NET MVC Fundamental
ASP.NET MVC Fundamental
ASP.NET MVC Fundamental
ASP.NET MVC Fundamental
ASP.NET MVC Fundamental
ASP.NET MVC Fundamental
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

ASP.NET MVC Fundamental

4,624

Published on

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
4,624
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
163
Comments
0
Likes
2
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • 3Mins
  • Estimated Time: 5 minutesThe Microsoft Web Platform is a complete stack for running powerful, rich web applications that scale easily too. It’s also easy to install thanks to the Web Platform Installer – a free, one click download that gets everything setup for you very quickly!At the foundation of the platform is Windows Server and Internet Information Services which provides a really powerful web server which you can rely on to serve up your web applications. For storing your application data, SQL Server is a robust and secure database which scales effectively to deliver huge datasets. Moving up the stack, the most effective way to map data to your application code is the Entity Framework, which now in v4, provides an ORM that allows you to code against multiple data sources without concerning yourself with writing database centric calls. At the application layer there are a couple of choices thanks to the flexibility of ASP.NET – either ASP.NET Web Forms or ASP.NET MVC – we’ll be discussing both these in more detail a little later.On the client we support and contribute towards the jQuery Core Library and plugins making JavaScript development easier as well as providing the Ajax Control Toolkit for Web Forms developers to easily create rich web applications.On the tooling side, Visual Studio 2010 provides software, support and collaboration features to deliver cool web applications.NotesSome notes on security – if needed.Web Server.Note that these numbers are run against specific advisories against IIS or Apache, and for consistency, we’re looking at the most recent 2 versions of each.IIS had 8 Security advisories directly associated with it. (2 for IIS7, 6 for IIS 6)Apache had 56 Security advisories (17 for 2.2.x and 39 for 2.0.x)As of February 2010, IIS 7 has 0 unpatched advisories, and IIS 6 has 1 unpatched advisory. Apache 2.2.x has 2 unpatched advisories, and Apache 2.0.x has 4 unpatched advisories.Conclusion: Not only does IIS have less advisories against it, Microsoft also demonstrate that they are quicker to patch these advisories.DatabaseNote that these numbers are run against advisories for specific versions of SQL Server and MySQL. As such we’re using the most recent 2 versions of each.SQL Server had 4 Security advisories (0 for SQL Server 2008, 4 for SQL Server 2005)MySQL had 44 Security advisories (20 for MySQL 5.x, 22 for MySQL 4.x)As of February 2010, SQL Server had 0 unpatched advisories, and MySQL has 4 unpatched advisories.Conclusion: Not only does SQL Server have less advisories against it, Microsoft also demonstrate that they are quicker to patch these advisories.Application Framework.Note that ASP.NET is in the .NET framework, so the numbers are for the framework as a whole. Note also that as the advisories are published for specific versions, we’re looking at the last two versions of each..NET had 9 total advisories (2 for .NET 3.x, 7 for .NET 2.x)PHP had 28 total advisories (2 for 5.3.x, 26 for 5.2.x)There are 0 unpatched advisories for /NET, there are 5 unpatched advisories for PHP.
  • 2 minutesWhen we look at all the different profiles of people creating websites we see certain patterns emerge. First, there is a group of people that want to easily create simple web sites to share information about their hobbies, work, to share photos, and so on. Web Apps are overkills for them. They just need to get the site up and running rapidly from scratch.There’s another group of people that like to use the large number of rich web applications out there as a starting point, they need to get to a solution quickly and in an easy way. Many of this web apps are tailored for specific tasks, and provide 80% of the functionality of a solution; the developer just need to customize them and publish them.Finally, there are the professional developers that need to build complex and scalable web sites. For this, they need tools that help them work in a team, source and version control, a testing framework, and tools with lots of powerful extensions.
  • The ASP.NET MVC simplifies the complex parts of ASP.net Web Forms without any compromise of the power and flexibility of ASP.NET platform. ASP.net MVC implements Model-View-Controller UI pattern for web application development that lets you allows to develop applications in a loosely couples manner. MVC pattern is separating the application in three parts- Model, View and Controller. A view is responsible for rendering the user interface (UI) of the application and it is nothing more than html templates that filled with application’s data passed by the controller. The Model implements the logic for the application's data and it represents the business objects of the application that using the View for rendering user interface. Controllers are handles and responds to user input and interaction. The web request will be handled by the controller, and the controller will decide which model objects to use and which view objects to render. The MVC model replaces the Web Form events with the controller actions. The main advantages of the MVC models are clear separation of concerns, unit testing facility, and more control over the URLs and HTML. The MVC model does not use Viewstate, Postbacks, Server controls, and server-based forms that enable full control over the application and html rendered by the Views. MVC model is using Representational state transfer (REST) based URLs instead of file-name extensions used by the Web Form model so that we can make search engine optimization (SEO) URLs published by the application
  • Estimated Time: 2 mins
  • Estimated Time: 2 minutesFinally, we got to the C (from MVC), the Controllers.Controllers are responsible of receiving user requests and taking care of them accordingly. In general, controllers would create a model, which they fill with data from a persistence source like a database and pass it to a view.
  • Estimated Time: 2 minutesLet’s first start by the M (of MVC), the Models.Models are the mean of communication between the controllers and the views. Whenever a controller processes a request from the user and has to display information, it creates the model and passes it to the view. The model only holds data. It doesn’t know anything about the application logic or how to display itself.
  • Estimated Time: 2 minutesNow let’s continue with the V (from MVC), the Views.Views are visual representations of the models. They are responsible for displaying a model or part of it to the user. The views don’t hold application logic.Note that there can be many views of the same model. Maybe one view displays the name and address of a customer while other displays the telephone and the orders from that same customer but both rely on the same model: the customer.
  • Estimated Time: 3 minutesThe primary framework goals of ASP.NET MVC are…Frictionless testability– By “frictionless” I mean that when you want to test your code, the framework it was written it doesn’t cause you friction. This is very important if you want to seriously perform long-term unit testing on an application, because if developers were constantly running into points of friction when trying to test, they would eventually abandon it.Tight cover over markup – ASP.NET MVC doesn’t contain any server controls or high-level abstractions that mask their underlying rendering. When you develop an ASP.NET MVC application, you have complete control over the markup. ASP.NET MVC does include some HTML helpers that “hide” away some HTML, but they are at the most basic level of rendering (i.e. just an <input> element).Leverage the benefits of ASP.NET – Because ASP.NET MVC is built on top of the core ASP.NET runtime, you still have plenty of old-friends that can be used (i.e. profiles, membership, roles, caching). All of the same intrinsics you’ve always known are still valid and used heavily.Conventions and guidance – ASP.NET MVC comes with a set of predefined conventions that make the use of it much easier, without the need to for tons of configuration. It also provides framework-level guidance. The idea is that ASP.NET MVC wants to try to lead developers down the pit of success.
  • Transcript

    • 1. ASP.NET MVC 3 Training for Heroes <br />WELCOME TO MVC SHINE DAY<br />LêDươngCôngPhúc<br />SESSION 1: ASP.NET MVC FUNDAMENTAL<br />
    • 2. Who am I?<br />LêDươngCôngPhúc<br />Technical evangelism<br />Software engineer at Vina Digital Co,. Ltd.<br />
    • 3. Active Server Pages<br />Visual Studio 98:<br />ASP, VBScript, ADO<br />Request, Response object<br />
    • 4. Evolution of ASP.net #2: ASP 1.0, 1.1, 2.0<br />ASP.net 1.0: January 16th 2002<br />ASP.net 1.1: April 24th 2003<br />ASP.net 2.0: Nov 7th 2005, Visual Studio 2005<br />New data controls (GridView, FormView, DetailsView)<br />Declarative data access (SqlDataSource, ObjectDataSource, XmlDataSource controls)<br />Navigation controls<br />Master pages<br />Login controls<br />Themes<br />Skins<br />Web parts<br />Personalization services<br />Full pre-compilation<br />New localization technique<br />Support for 64-bit processors<br />Provider class model<br />Code Behind,Web Form, <br />ViewState<br />
    • 5. ASP.net 3.0, 3.5, 3.5 SP 1<br />ASP.net 3.0: Nov 21 2006 : WCF, CardSpace<br />ASP.net 3.5: Nov 19 2007, released with VS2008:<br />LINQ Data Source<br />New data controls (ListView, DataPager)<br />ASP.NET AJAX included as part of the framework<br />Support for HTTP pipelining and syndication feeds.<br />WCF Support for RSS, JSON, POX and Partial Trust<br />ASP.net 3.5 sp1: Aug 11 2008:<br />Dynamic Data<br />Browser history in an ASP.NET AJAX<br />Combine multiple Javascript files into a single file<br />New namespaces System.Web.Abstraction and System.Web.Routing<br />ASP.NET 4.0<br />Easier to get started, develop and deploy<br />Routing and Search Engine Optimization<br />Productivity & Extensibility<br />
    • 6. The Microsoft Web Platform<br />Web Platform Installer<br />Ajax Control Toolkit & jQuery<br />ASP.NET<br />ADO.NET Entity Framework<br />SQL Server<br />IIS<br />The Microsoft Web Platform combines a rich and powerful web application framework with a supporting cast of tools, servers,technologies and applications for creating, designing, developing and delivering web solutions. <br />
    • 7. Web Platform Installer<br />Makes it easy to install the Microsoft Web Platform from one place<br />Framework, Web Server, Database and Tools <br />Cost = free; Size < 2MB<br />Always has latest version of the platform available<br />Available in 9 languages<br />Web App Gallery<br />Umbraco, DotNetNuke, Drupal, WordPress and many more<br />Submit your own apps, get distribution<br />
    • 8. Today’s Web Developers<br />I want to build web sites myself with an easy to learn tool and framework<br />I’m a professional software developer and I build complex, large scale web sites with a team of developers<br />I <3 Web Apps. I just need a tool that makes them easier to configure, customize and publish them<br />
    • 9. Goals of ASP.NET MVC<br />Clean URL schemes<br />Support existing ASP.NET runtime features<br />Build on top of System.Web, doesn’t replace it<br />Enable clean separation of concerns<br />Testable by default (built with TDD in mind)<br />Support third-party view engines<br />Auto-mapping of form variables to object properties<br />Provides complete control over your HTML markup<br />Enables rich JavaScript, AJAX integration<br />
    • 10. Key Concepts<br />Controller<br />Factory<br />Controller<br />forwards<br />MvcHandler<br />creates<br />Model<br />invokes<br />Action<br />uses<br />produces<br />produces<br />View<br />Result<br />Action<br />Result<br />View<br />Engine<br />defines<br />View<br />renders<br />
    • 11. MVC Pattern<br />Model<br />Decouples the backend business logic from the front end<br />Binds the model and view together and selects which view to display next<br />Data Transfer<br />Event Notification<br />Data Transfer<br />Controller<br />Request<br />Business InteractionLayer<br />User InteractionLayer<br />View<br />Response<br />Visualizes the application data supplied by the model<br />
    • 12. How MVC Works<br />What does MVC look like?<br />Controller<br />Controller<br />Retrieves Model<br />“Does Stuff”<br />Request<br />View<br />View<br />Visually represents<br />the model<br />Response<br />
    • 13. Introducing “MVC Shine” application<br />Features<br />View detail about asp.net mvc activities of heroes<br />Rate an activity<br />What you are doing to see today<br />Build the first ASP.NET MVC application<br />ASPX view engine<br />Learning about ASP.NET MVC 3 fundamental<br />Razor view engine<br />Implementing simple functionalities (CRUD, master-detail)<br />
    • 14. Controllers<br />View<br />Controller<br />Request<br />Controllers handle requests from the user<br />Controllers create the model for the views<br />Application logic is placed in the controllers<br />
    • 15. Models<br />View<br />Controller<br />The models hold the application data<br />Models are the mean of communication between the controllers and the views<br />Models hold no application logic<br />
    • 16. Views<br />View<br />Views are visual representations of a model<br />There can be many views for the same model<br />Views contain no application logic<br />
    • 17. URL routing<br />Web form: without query string, an URL maps to one aspx page<br />MVC: URL maps to Controller/Action/RoutesValues<br />/Company/Details/3<br />Controller = CompanyController<br />Action = Details<br />Route Value = {ID = 3}<br />/News<br />Controller = NewsController<br />Action = Index<br />Route Value = null<br />
    • 18. Action Result<br />The ActionResultclass is the base for all action results. However, there are different action result types, depending on the task that the action method is performing. <br />The most common action is to call the View method. The View method returns an instance of the ViewResultclass, which is derived from ActionResult.<br />
    • 19. Action Result Examples<br />Return JSON<br />[AcceptVerbs(HttpVerbs.Get)]<br />public ActionResultGetSubSkill(int id)<br />{<br /> return Json(db.GetSkills(id)); //Return data in JSON format<br />}<br />$.getJSON("/Skill/GetSubSkill/" + $(this).attr("id"), function(data) {<br />Returns JavaScript<br />[AcceptVerbs(HttpVerbs.Get)]<br />public JavaScriptResultJAction()<br />{<br />return JavaScript("alert('HelloWorld')");<br />}<br />…<br /><script type="text/javascript" src="/Home/JAction"></script><br />
    • 20. MVC UI Helper Controls<br />The HtmlHelper class renders Html fragments of views.<br />Basic MVC UI Helper Controls<br />Html.ActionLink(), Html.BeginForm(), Html.CheckBox(), Html.DropDownList(), Html.EndForm(), Html.Hidden(), Html.ListBox(), Html.Password(), Html.RadioButton(), Html.TextArea(), Html.TextBox()<br />MVC UI Helper Controls can be extended using extension method.<br />http://www.asp.net/Learn/mvc/tutorial-09-cs.aspx<br />
    • 21. Framework Goals<br />Frictionless Testability<br />Tight control over <markup><br />Leverage the benefits of ASP.NET<br />Conventions and Guidance<br />
    • 22. MVC vs Web Form<br />MVC is just another choice of technologies for web development using ASP.NET. <br />Web forms is still well developed and supported<br />

    ×