Introducing ASP.NET MVC : Introducing ASP.NET MVC Alan Dean, Senior Technologist
MVC consists of three kinds of objects : MVC consists of three kinds of objects
Slide7 : Controller Model View
Slide10 : Controller View Model handleEvent service update getData
Separation of Concerns (SoC) : Separation of Concerns (SoC)
MVC Web Frameworks : MVC Web Frameworks
.NET MVC Web Frameworks : .NET MVC Web Frameworks
Demo : Demo Create a new ASP.NET MVC Solution
HTTP Request Flow : HTTP Request Flow HTTP Response GET /Home/Index HTTP/1.1 HTTP Request Route Handler Controller Model View
HTTP Request Flow : HTTP Request Flow public class Global : HttpApplication
{
protected void Application_Start(object sender, EventArgs e)
{
RouteTable.Routes.Add(new Route
{
Url = "[controller]/[action]/[id]",
Defaults = new { action = "Index", id = (string)null },
RouteHandler = typeof(MvcRouteHandler)
});
}
} HTTP Response Route Handler HTTP Request Controller Model View
HTTP Request Flow : HTTP Request Flow public class HomeController : Controller
{
[ControllerAction]
public void Index()
{
CompanyInfo companyInfo = new CompanyInfo();
companyInfo.CompanyName = "Your company name here";
RenderView("Index", companyInfo);
}
} HTTP Response Controller HTTP Request Route Handler Model View
HTTP Request Flow : HTTP Request Flow public class CompanyInfo
{
public string CompanyName { get; set; }
} HTTP Response Model HTTP Request Route Handler Controller View
HTTP Request Flow : HTTP Request Flow public partial class Index : ViewPage
{ } Response View <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Index.aspx.cs"
Inherits="MvcApplication.Views.Home.Index" %>
<%= this.ViewData.companyName %>
<%= Html.ActionLink(“Homepage", "Index", "Home") %>
Welcome!
HTTP Request Route Handler Controller Model
HTTP Request Flow : HTTP Request Flow HTTP/1.1 200 OK
Content-Type: text/html
Your company name here
Index
Welcome!
HTTP Request Route Handler Controller Model View HTTP Response
Wiki : Wiki A wiki is software that allows users to create, edit, and link web pages easily
Wiki Database : Wiki Database
Wiki HTTP API : Wiki HTTP API
GET : GET
POST : POST
PUT : PUT
DELETE : DELETE
REST: The Web Used Correctly : REST: The Web Used Correctly
REST is an Architectural Style : REST is an Architectural Style
Deriving REST : Deriving REST
Uniform Interface : Uniform Interface
Benefits of REST : Benefits of REST