ASP.NET Webform application was a revolutionary way to bring Windows type applications to the internet.   ASP.NET Beta’s came out over 12 years ago.

 

The problem with ASP.NET Webforms and the Postback model:  It breaks the Internets!

 

Through foresight, evolution, and chance, the internet (and the W3C) has a refined set of powerful semantics that has built the web into indispensible super system it is today.

 

There are POWERFUL and simple standards the W3C supports through a competitive field of web browsers.  Over 10 years ago, ASP.NET helped hide away the messy, young internet standards.  It was a huge success.  But now,  some it abstracts away what are powerful and simple standards from the WebForm software engineer.

 

  • XHTML – a refined standard of HTML.  XHTML is first a foremost, a valid XML document.  This makes parsing Document DOM’s easier.  (See <BR> vs <BR/>).  This makes extending XHTML standards easier and faster, like HTML5.
  • JAVASCRIPT – With the help of cross-browser JS libraries JQuery and YAHOO YUI, this difficult language now becomes powerful and simpler.
  • FORM tag – powerful in it’s own right, but simple and requires no javascript to build a web application.  You already know that FORM tags can put their parameters to a FORM POST or QueryString automagically? Of course!
  • CSS – Separates formatting from style.  ASP.NET 4.0 Web controls finally give MOST of this power back to the CSS rather than inline styles.  Since ASP.NET MVC, this powerful styling was adopted completely. This keeps MOST software engineers out of the ‘STYLE’ business.  No more INLINE styles!

 

A large reason the internet has grown in unpredictable ways (MASHUPS? ??, RSS, REDDIT.com) is because of an important Architectural pattern:

 

The RESTful Architectural pattern states that a web application should be:

 

1.    Client / Server

2.    Stateless

3.    Cacheable – Web Proxy and Client Cachable.

4.    Layered System – Javascript layers to CSS to HTML to HTTP to ASP.NET

5.    Code on Demand – Javascript

6.    Uniform Inteface – HTML5 ?

Unfortunately, most ASP.NET Web form applications usually break rules #2 and #3.   Because POST backs are used almost exclusively in most WebFrom or DynamicData applications that are NOT cacheable.  Most of the time, they are not bookmarkable (#2 – Stateless).

 

ASP.NET MVC and WCF Services and others new Microsoft patterns are designed for the RESTful web.

 

The primary design pattern in ASP.NET MVC is Actions using the CRUDL (Create, Read, Update, Delete and List) pattern.  MVC was a widely successful design pattern borrowed from JAVA which borrowed from SmallTalk.

 

Modern web application use CRUDL in alignment with the RESTful pattern.

The ‘Read’ and ‘List’, commonly called ‘Details’ and ‘List’, use ONLY URL with Querystring to retrieve the web page.   These are considered NON-destructive actions.  They use the HTTP GET verb, which SHOULD be cachable.  Every search page you have seen is really a ‘LIST’ page.  Cached search results AT the CLIENT make your application fly!

The ‘Create’ (‘Insert’), ‘Update’ and ‘Delete’ are broken into two ‘Actions:  first is a GET then a POST.

The first GET will retrieve the read-only data that helps the user update or insert the new data.  This is an empty web form or a web form with the current version of the data, or a warning "Are you sure you want to Delete this?"

Once the user hits the submit button, it POSTs the ‘Update’ or ‘Inserted’ data to the Server using an HTTP POST verb.  POSTs by default are NOT CACHABLE, nor should they be.   These are destructive ACTIONS.

Sometime when you ever hit refresh on a page, and it says "Are you sure you want to RESEND this data?"   If it’s a RESTFUL site, the answer is always no; you are performing a DESTRUCTIVE action.  Any Action that CHANGES data on the SERVER should be a POST.  You just tried to REFRESH a POST, and the web browser, by standards, tries to tell you NOT to do this.

The RESTful pattern helped create a more reusable, scalable web.  In typical Microsoft fashion, they create OR ADAPT.

ASP.NET MVC, now in its 3rd major release, was Microsoft’s first major open source project.  It has been wildly successful.  It gets rid of the POSTBACK STATEFUL model and helps follow the SEMENTIC web so web sites can scale, be reused, and reformulated in ways the original authors never intended. 

 

So during your ASP.NET MVC development, remember the RESTful design principles:

  • Stay away from state (Session; Stateful controls)
  • Consider browser caching early in your design.  Cache even for 30 seconds helps!
  • Use the proper GET / POST depending on CRUDL action.
  • Allow separation of View; layer javascript on top.
  • Consider Stateless services to support JQuery UI elements.

These patterns are SO powerful; they have created similar STANDARDS for non-HTML clients. 

iOS, Android and Windows Mobile 7 all almost REQUIREs developers to use a MVC type pattern  that usually relies on ATOM XML services.

 

Also, keep these patterns in mind for your ASP.NET Web Form applications.  If it’s a non-destructive action, like a Search or Navigation, use QueryString parameters, instead of POSTBACK or Webform.   

 

ASP.NET MVC is not just a web application tool, it is a marriage of asp.net, the internet standards, and RESTful architecture.