67
Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. [email protected]

Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. [email protected]

Embed Size (px)

Citation preview

Page 1: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

Building a Next-Generation Web Applicationwith ASP.NET MVC 2 and jQuery

Nate KohariCo-Founder / CTOEnkari, [email protected]

Page 2: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

Who?

Page 3: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com
Page 4: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com
Page 5: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

Goals

Page 6: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

ASP.NET is a great platformfor building attractive, standards-compliant

rich internet applications

Page 7: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

You can build rich internet applications withoutSilverlight or Flash

Page 8: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

Why ASP.NET MVC?

Page 9: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

BizSpark

Page 10: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

Why jQuery?

Page 11: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

(demo)

Page 12: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

User Action

Metadata Lookup

Route Lookup

Filters

Domain Service

Event Broadcast

Anatomy of a typicalZen request

Page 13: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

User Action

Metadata Lookup

Route Lookup

Filters

Domain Service

Event Broadcast

ASP.NET MVC

HTML/JavaScript

Page 14: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

User Action

Metadata Lookup

Route Lookup

Filters

Domain Service

Event Broadcast

Page 15: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

JS.Class

Page 16: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

Zen.Ui.StoryCard = new JS.Class({ func1: function() { ... }, func2: function() { ... }});

var card = new Zen.Ui.StoryCard();

Page 17: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

Behaviors

Page 18: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

$(“.story-card”).attach( Zen.Ui.Behaviors.StoryCard);

Page 19: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

Find all elements with the CSS class story-card…

$(“.story-card”).attach( Zen.Ui.Behaviors.StoryCard);

Page 20: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

…and apply the appropriate behavior

$(“.story-card”).attach( Zen.Ui.Behaviors.StoryCard);

Page 21: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

Which card did theuser move?

Page 22: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

User Action

Metadata Lookup

Route Lookup

Filters

Domain Service

Event Broadcast

Page 23: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

<li data-projectid=“123” data-storyid=“456”> ...</li>

HTML5 data-* attributes

(story card)

Page 24: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

<li data-projectid=“123” data-storyid=“456”> ...</li>

HTML5 data-* attributes

(story card)

{ projectid: 123, storyid: 456 }

JSON read via Metadata Plugin

Page 25: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

Where should we sendthe request?

Page 26: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

User Action

Metadata Lookup

Route Lookup

Filters

Domain Service

Event Broadcast

Page 27: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

One Action = One Route

Page 28: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

One Action = One Route(“route-per-action”)

Page 29: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

<app> <project> <route action=“move” pattern=“project/{projectid}/story/{storyid}/move” verbs=“post”/> ... </project> ...</app>

Routes defined in XML:

Page 30: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

<app> <project> <route action=“move” pattern=“project/{projectid}/story/{storyid}/move” verbs=“post”/> ... </project> ...</app>

Routes defined in XML:

…at app start, parsed & registered in RouteTable

Page 31: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

<app> (area) <project> <route action=“move” pattern=“project/{projectid}/story/{storyid}/move” verbs=“post”/> ... </project> ...</app>

Routes defined in XML:

Page 32: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

<app> <project> (controller) <route action=“move” pattern=“project/{projectid}/story/{storyid}/move” verbs=“post”/> ... </project> ...</app>

Routes defined in XML:

Page 33: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

<app> <project> <route action=“move” pattern=“project/{projectid}/story/{storyid}/move” verbs=“post”/> ... </project> ...</app>

Routes defined in XML:

Page 34: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

Url.Action(“move”, “story”, new { projectid = 123, storyid = 456 })

Page 35: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

Url.Action(“move”, “story”, new { projectid = 123, storyid = 456 })

http://agilezen.com/projects/123/story/456/move

Page 36: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

But wait… we needthe route in JavaScript!

Page 37: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

urlfor()

Page 38: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

urlfor(“move”, “story”, { projectid: 123, storyid: 456 })

Page 39: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

urlfor(“move”, “story”, { projectid: 123, storyid: 456 })

http://agilezen.com/projects/123/story/456/move

Page 40: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

urlfor(“move”, “story”, { projectid: 123, storyid: 456 })

Metadata read from story card <li>

Page 41: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

routes.js

Page 42: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

User Action

Metadata Lookup

Route Lookup

Filters

Domain Service

Event Broadcast

Page 43: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

User Action

Metadata Lookup

Route Lookup

Filters

Domain Service

Event Broadcast

ASP.NET MVC

HTML/JavaScript

Page 44: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

Aspect Oriented Programming

Page 45: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

[Demand]

Page 46: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

[Demand(Permission.EditStory)]

Page 47: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

[Secured]

Page 48: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

[Secured(SSLMode.Force)]

Page 49: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

[Transactional]

Page 50: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

Output Filters

Page 51: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

[DoNotCache]

Page 52: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

[StripWhitespace]

Page 53: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

[HandleExceptions]

Page 54: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

User Action

Metadata Lookup

Route Lookup

Filters

Domain Service

Event Broadcast

Page 55: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

Filters SecurityOther cross-cutting concerns

Page 56: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

ControllerInterprets requestsCommunicates with browserSets up view data

Filters SecurityOther cross-cutting concerns

Page 57: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

Controller

Domain Service

Interprets requestsCommunicates with browserSets up view data

Modifies data modelBroadcasts events

Filters SecurityOther cross-cutting concerns

Page 58: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

Controller

Domain Service

Repository

Interprets requestsCommunicates with browserSets up view data

Modifies data modelBroadcasts events

Persists data to database

Filters SecurityOther cross-cutting concerns

Page 59: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

Controller

Domain Service

Repository

Filters

LINQ

NHibernate

Page 60: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

User Action

Metadata Lookup

Route Lookup

Filters

Domain Service

Event Broadcast

Page 61: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

Messenger

SMTP Service

Domain Service

XMPP Service

Page 62: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

Messenger

SMTP Service

Domain Service

XMPP Service

Events queued

Page 63: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

Messenger

SMTP Service

Domain Service

XMPP Service

Events queued

Page 64: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

Messenger

SMTP Service

Domain Service

XMPP Service

Email notifications IM notifications

Events queued

Page 65: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

User Action

Metadata Lookup

Route Lookup

Filters

Domain Service

Event Broadcast

Recap

Page 66: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com
Page 67: Building a Next-Generation Web Application with ASP.NET MVC 2 and jQuery Nate Kohari Co-Founder / CTO Enkari, Ltd. nate@enkari.com

Thanks for listening!Nate Koharihttp://kohari.orghttp://[email protected]@nkohari