asp.net mvc

16
Phuc Le Cong

Upload: lanh-nhu-bang

Post on 21-May-2015

873 views

Category:

Technology


2 download

TRANSCRIPT

Page 1: Asp.net mvc

Phuc Le Cong

Page 2: Asp.net mvc

Contents

Overview of ASP.Net. Introduction ASP.Net MVC 2.0. Characteristic in ASP.Net MVC. Project structure. Different from WebForm. Demo.

Page 3: Asp.net mvc

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.

Page 4: Asp.net mvc

Overview of ASP.Net (cont)

Execute

Page 5: Asp.net mvc

Introduction ASP.Net MVC 2.0

The Basic MVC Model

Page 6: Asp.net mvc

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

Page 7: Asp.net mvc

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

Page 8: Asp.net mvc

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...

Page 9: Asp.net mvc

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

Page 10: Asp.net mvc

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

Page 11: Asp.net mvc

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

Page 12: Asp.net mvc

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 .

Page 13: Asp.net mvc

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.

Page 14: Asp.net mvc

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.

Page 15: Asp.net mvc

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

Page 16: Asp.net mvc

The end.Thank for watching!