Labels

Monday, July 20, 2009

Web Forms And ASP.NET MVC

Hi,

 

Based on server controls, ASP.NET allows developers to build real-world Web sites and applications with minimal HTML and JavaScript skills.

The whole point of ASP.NET is productivity, achieved thru powerful set of server controls, user controls, postback events, viewstate, forms authentication, and intrinsic objects.

The model behind ASP.NET is called Web Forms. ASP.NET allows developers to build real-world Web sites and applications with minimal HTML and JavaScript skills.

 

So why did Microsoft release "another" ASP.NET framework, called ASP.NET MVC?  To read more use below.

 

MSDN article on – ‘Comparing Web Forms and ASP.NET MVC’ - Link

Please go thru the reference to read out in detail. However below are the highlights on this topic.

 

Drawbacks of Web Forms

 

-          Separation of concerns (SoC) has not been a natural fit with the Web Forms paradigm.

-          ASP.NET Web Forms is based on a monolithic runtime environment that can be extended, to some extent, but it is Not A Pluggable And Flexible system. It's nearly impossible to test an ASP.NET application without spinning up the whole runtime.

-          Abstraction from HTML is a serious issue as it hinders accessibility, browser compatibility, and integration with popular JavaScript frameworks like jQuery, Dojo, and PrototypeJS

-          The postback model that defaults each page to post to itself, results in Lower Rank For Search Engines to rank ASP.NET pages high. Search engines and spiders work better with links with parameters, better if rationalized to human-readable strings. The postback model goes in the opposite direction.

-          Also, an excessively large viewstate is problematic because the keyword the rank is based on may be located past the viewstate, and therefore far from the top of the document. Some engines recognize a Lower Rank in this case.

 

 

 

Benefits of ASP.NET MVC

 

-          With ASP.NET MVC, you rediscover the good old taste of the Web—stateless behavior, full control over every single bit of HTML, total script and CSS freedom.

-          ASP.NET MVC is a completely new framework for building ASP.NET applications, designed from the ground up with SoC and Testability in mind.

-          When you write an ASP.NET MVC application, you think in terms of controllers and views. You make your decisions about how to pass data to the view and how to expose your middle tier to the controllers. The controller chooses which view to display based on the requested URL and pertinent data. Each request is resolved by invoking a method on a controller class.

 

-          No postbacks are ever required to service a user request.

-          No viewstate is ever required to persist the state of the page.

-          No arrays of black-box server controls exist to produce the HTML for the browser.

 

-          The HTML served to the browser is generated by a separate, and Replaceable, Engine.

-          There's No Dependency on ASPX physical server files. ASPX files may still be part of your project, but they now serve as plain HTML templates, along with their code-behind classes.

 

-          The runtime environment is largely the same as in ASP.NET Web Forms, but the Request Cycle is simpler and more direct.

-          An essential part of the Web Forms model, the Page Lifecycle, Is No Longer necessary in ASP.NET MVC

 

 

 

 

The Right Perspective

 

-          As an architect or developer, it is essential that you understand the structural differences between the frameworks so that you can make a thoughtful decision. All in all, ASP.NET Web Forms and ASP.NET MVC are Functionally Equivalent in the sense that a skilled team can successfully use either to build any Web solution.

 

-          Microsoft has not positioned ASP.NET MVC as a replacement for ASP.NET Web Forms.

-          Web Forms is definitely a pattern that works for Web applications. At the same time, Ruby-on-Rails has proved that MVC can also be a successful pattern for Web applications; and ASP.NET MVC confirms this.

 

-          Web Forms embraces the RAD philosophy whereas ASP.NET MVC is TDD-oriented.

-          Further, Web Forms goes toward an abstraction of the Web that simulates a stateful environment, while ASP.NET MVC leverages the natural statelessness of the Web and guides you towards building applications that are Loosely Coupled and Inherently Testable, Search-Engine Friendly, and with Full Control Of Html.

 

 

At the End of the Day

 

-          We have seen that there are pros and cons in both Web Forms and ASP.NET MVC. Many developers, however, seem to favor ASP.NET MVC because it represents the only way to get SoC and testability into their applications. Is it really the only way? No.

-          However, ASP.NET MVC makes it easier and natural to achieve SoC and write more testable code.

-          ASP.NET MVC doesn't magically transform every developer into an expert architect and doesn't prevent developers from writing bloated and poorly designed code.

 

At the end of the day, both Web Forms and ASP.NET MVC help to build applications that are designed and implemented to deal effectively with the complexity of real-world solutions. No software magic exists, and none is yet supported by the ASP.NET platform.

 

Hope this helps.

 

Thanks & Regards,

Arun Manglick || Senior Tech Lead

 

 

No comments:

Post a Comment