Asp.net mvc
-
Upload
lanh-nhu-bang -
Category
Technology
-
view
873 -
download
2
Transcript of Asp.net mvc
Phuc Le Cong
Contents
Overview of ASP.Net. Introduction ASP.Net MVC 2.0. Characteristic in ASP.Net MVC. Project structure. Different from WebForm. Demo.
Overview of ASP.Net
ASP.NET is abbreviation of Active Server Pages .NET
Integrate .Net framework. Multilingual. Object – Oriented progamming. To be compiled. To be stored on machine by CLR. Easy deployment and configuration.
Overview of ASP.Net (cont)
Execute
Introduction ASP.Net MVC 2.0
The Basic MVC Model
Controllers
Action Result Type Exemples of Use(in action methods)
ViewResult Return View();Return View(“view”, model Object);
PartialViewResult Return PartialView();Return PartialView(“partialview”, modelObject);
RedirectToRouteResult
Return RedirectToRoute(“LogOn”);
RedirectResult Return Redirect(“http://www.microsoft.com”);
ContentResult Return Content(rss,” application/rss+xml”);
FileResult Return File(“chart.ptt”, “application/ptt”);
JsonResult Return Json(someObject);
JavaScriptResult Return JavaScript(“$(‘#table’).init();”);
HttpUnauthorizedResult
Return new HttpUnauthorizedResult
EmptyResult Return new EmptyResult();
Built-in Action Result Types
Views
Technique Description
Inline Code The same old <%...%> and <%=...%>
Html Helpers Built-in or extension methods for Html Helpers class,e.g. Html.TextBox(...), Html.BeginForm(...) etc
Partial Views Render user controls,which can be reused in many places,e.g. Html.RenderPartial(“ProductEdit”).
Partial Actions Invoke an MVC action and render resulted action resulte.g. Html.RenderAction(“ProductCount”).
Server Controls Use standard ASPX control registration and using syntax
Dynamic Code Options
Characteristic in ASP.Net MVC
Separate clear relationships, open probability test TDD (test driven developer).
Have a probability of extend, easily replace and customize.
Allow to build application with URL cleanly. Support same files such as: .aspx, .ascx, .master,
etc... Support all features about security:
forms/windows authentication, URL authorization, session, etc...
Different from WebForm
Architecture of programming ASP.NET 2.0:
Architecture model Webform→Business→ Database ASP.NET MVC 2.0:
Architecture use divided programming into Controllers, Models, Views
Different from WebForm(cont)
Syntax of programming ASP.NET 2.0:
Uses syntax of webform, events and controls managed by server
ASP.NET MVC 2.0:Events are controlled by controllers, controls not be managed by server
Different from WebForm(cont)
Access database ASP.NET 2.0:
Most of applications use technology to access database
ASP.NET MVC 2.0:Use Linq To SQL class
Different from WebForm(cont)
Debug ASP.NET 2.0:
Testing program include access database, display, controls,...
ASP.NET MVC 2.0:Can only test controller methods .
Different from WebForm(cont)
Running speed of the program ASP.NET 2.0:
Slowly when pages have too many controls, because of too much ViewStates.
ASP.NET MVC 2.0:It’s much faster , because it doesn’t use ViewState to manage controls in pages.
Different from WebForm(cont)
Interact with Javascript ASP.NET 2.0:
Difficult because it’s directly controlled by server. ASP.NET MVC 2.0:
Easy because objects are not controlled by server.
Different from WebForm(cont)
URL address ASP.NET 2.0:
Structure address URL have form: <filename>.aspx?&<parameters>
ASP.NET MVC 2.0: Structure address URL have form: Controller/Action/Id
The end.Thank for watching!