1 / 38

ASP MVC in A Web Hosted World

ASP.net MVC in A Web Hosted World. Jeff Ammons. The Atlanta Journal-Constitution Developer/DBA GGMUG.com President Gwinnett, Georgia, Microsoft User Group 2 nd Thursday, 6:30 PM Gwinnett Tech Blog: http://ammonsonline.com/jeffablog. Agenda. Define Hosted Environment Intro To MVC

erika
Download Presentation

ASP MVC in A Web Hosted World

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ASP.net MVC inA Web Hosted World

  2. Jeff Ammons • The Atlanta Journal-Constitution • Developer/DBA • GGMUG.com • President • Gwinnett, Georgia, Microsoft User Group • 2nd Thursday, 6:30 PM Gwinnett Tech • Blog: http://ammonsonline.com/jeffablog

  3. Agenda • Define Hosted Environment • Intro To MVC • Define Challenges • Explore Strategies

  4. What Is Hosted Environment? • Web • Shared Server • Managed By Hosting Company

  5. What’s Included? • Web Server • File Storage • Database • Bandwidth • Email

  6. Examples • GoDaddy • Hostgator • DiscountASP.net • Bizhostnet.com

  7. Data Persistence Options • MySQL • SQL Server • File Based • XML • JSON

  8. SQL Server • $15/month = Unlimited 200 MB DBs • Good basic set of functionality • Choice of access methods • LINQ To SQL • Entity Framework • ADO • Etc.

  9. SQL Server and MySQL

  10. Who Is This Environment For? • Start-ups • Non-profit organizations • Personal use

  11. Why Choose A Hosted Env? • Lost cost ($5-$20/month) • Quick Start • Fewer People Required • No hardware to buy • No hardware to maintain • No server room

  12. Challenges • Server Access • Server Options • Server Load • Dude, Where’s My Data? • Dude, Who Can See My Data?

  13. Microsoft vs FOSS:The FOSS Advantage • Lots of FOSS based sites (LAMP) • Lots of FOSS sample code • Zero start-up cost • MS stack seen as ugly and corporate-looking

  14. Microsoft vs FOSS:The Empire Strikes Back • Asp.Net MVC • JQuery supported • OFFICIALLY • Visual Studio • Express Edition • BizSpark • WebsiteSpark • You CAN achieve zero start-up cost • You CAN make good looking sites

  15. What is MVC? • Model • View • Controller

  16. ?? • Design Pattern • Microsoft Web Framework

  17. MVC Pattern Model Data + Biz Rules Controller Middle Man/Traffic Cop View Presentation UI

  18. Asp.Net Options SharePoint WebForms MVC ASP.NET

  19. MVC vsWebforms MVC Webforms • No controls • Full control of emitted HTML • Clean HTML emitted • Might take longer but you have total control of look and feel • Separation of Concerns • Easier for tests, TDD • Clean URLs • www.myblog.com/my_story • Lot of controls • Don’t need to do so much HTML • Viewstate makes HTML lovers cry • Quick but often “looks like Microsoft Website” • More tightly coupled • Not so clean URLs • www.myblog.com/blog.aspx?permalink=my_story

  20. Which To Choose? MVC Webforms • Internet Apps • UI is crucial • Attracting user is crucial • Users will leave if it doesn’t look sexy • Internal IT apps • Developer time is crucial • Fill biz need is crucial • Users won’t leave if it doesn’t look sexy None of these statements are absolutes!

  21. Demo Time • Hello, MVC World • jeffaBlogger

  22. How Do You Get MVC To Work In Hosted Env? • Request IIS 7 • Publish Your Project • Include MVC DLL if necessary

  23. Strategies For Success • ActionLink Sucks At Virtual Directories • www.mydomain.com • www.mydomain2.com • /root  mydomain.com • /root/mydomain2  mydomain2.com • www.mydomain2.com/mydomain2/my_story

  24. ActionLinkV • You can replace darned near anything in MVC • The source is Open • ActionLinkV replaces ActionLink • Add Helpers Directory • Add files to Helpers • Register in web.config

  25. Cache, Cache, Cache • Thanks to ASP.net plumbing • You just call it differently than webforms • Don’t hit the database if you don’t need to • Set in the CONTROLLER • Set for entire controller • Set for individual methods • Do NOT cache personal info! • Options • Set cache location • Vary by param

  26. Repository Model • Controller interacts with • Interface • Abstract Class • Different implementations • Entity Framework • Linq To Sql • Xml • Mock

  27. Linq To Objects • For small datasets • Query collections of objects • Use object serialization to save to disk • What it wants to be when it grows up • http://research.microsoft.com/en-us/projects/dryad/

  28. What Is LINQ? • Language INtegrated Query • SQL-like language construct for .Net • Joins • Tables • Objects • Both • Aggregation • Selection • Go to Jim Wooley’s session next!

  29. Example LINQ Query var orderedModuleList = from module in itemList.getList() orderby module.Name select module;

  30. LINQ To Lots Of Stuff • LINQ To Entities • LINQ To SQL • LINQ To Objects • LINQ To XML

  31. File System Options • POCO (Built-in .Net Serialization) • XML

  32. Why? Why? Why? • Not ALL apps (or portions of apps) need relational databases • Burn the heretic!!! • SMALL datasets • Lots of Readers/Few Publishers • Blog • Informational site • Personal site • Excessive DB Traffic

  33. Example • Custom ASP.Net Membership Provider • Basic log-on info • Works great with 10-30,000 users • Total DOG with 500,000 users • No calls to DB server • Most start-ups would KILL to get 10,000 users

  34. CSS Themes • Standards Compliant • http://www.freecsstemplates.org/ • Create base class for your controllers • Put link into ViewData • Since it is in the base of all your controllers, all controllers will pass it to the views

  35. Security • HTML Encode as much data as possible • Variety of Javascript attacks • Use AntiForgeryToken helper

  36. Demo Time

  37. Goals For Your Project • Website itself • Web app others can use

  38. Helpful Links • MVC • http://www.asp.net/mVC/ • Blogs • http://weblogs.asp.net/Scottgu/ • http://haacked.com • http://www.hanselminutes.com/ • Sites • http://www.nerddinner.com/ • http://stackoverflow.com/

More Related