Advertuse

Search This Blog

Your Ad Here

Sunday 15 May, 2011

Difference b/w ASP.NET Webform and ASP.NET MVC

ASP.NET webfrom and ASP.NET MVC are two flavor of ASP.NET application development methodology provided by Microsoft. There are few similarity in both due to same platform but has many dissimilarity which one needs to understand to adopt ASP.NET MVC who previously worked with ASP.NET Webform technology.


ASP.NET WebForms
ASP.NET MVC
Uses the ‘Page Controller’ pattern. Each page has a code-behind class that acts as a controller and is responsible for rendering the layout.
Uses the ‘Front Controller’ pattern. There is a single central controller for all pages to process web application requests and facilitates a rich routing architecture
Uses an architecture that combines the Controller (code behind) and the View (.aspx). Thus the Controller has a dependency on the View. Due to this, testing and maintainability becomes an issue.
ASP.NET MVC enforces a "separation of concerns". The Model does not know anything about the View. The View does not know there’s a Controller. This makes MVC applications easier to test and maintain
The View is called before the Controller.
Controller renders View based on actions as a result of the User Interactions on the UI.
At its core, you ‘cannot’ test your controller without instantiating a View. There are ways to get around it using tools.
At its core, ASP.NET MVC was designed to make test-driven development easier. You ‘can’ test your Controller without instantiating a View and carry out unit-tests without having to run the controllers in an ASP.NET process.
WebForms manage state by using view state and server-based controls.
ASP.NET MVC does not maintain state information by using view state
WebForms supports an event-driven programming style that is like Windows applications and is abstracted from the user. The State management is made transparent by using sessions, viewstate etc. In the process, the HTML output is not clean making it difficult to manage later. The ViewState also increases your page size.
In ASP.NET MVC, the output is clean and you have full control over the rendered HTML. The orientation is towards building standard compliant pages and provides full control over the behavior of an application.
Deep understanding of HTML, CSS and JavaScript is not required to a large extent since the WebForm model abstracts a lot of these details and provides automatic plumbing. While abstracting details to provide ease of use, sometimes a solution is overcomplicated, than it needs to be.
A thorough understanding of how HTML, CSS and JavaScript work together is required. The advantage is you can do a lot of jQuery and AJAX stuff in an efficient and simple manner than you would do in an ASP.NET application.
WebForms can drastically reduce time while building up intranet and internet applications that use a lot of controls (drag and drop model). Although this is true for development, a lot of time is spent later to code around limitations.
You lose the 'drag and drop' quick model of building your web applications. The focus is on control over the application behavior and test-driven development. The model is extensible and you do not have to spend time working around limitations.
Relatively simple to learn and pickup. Works very well for developers who initially have trouble with the HTTP/HTML model and are coming from a similar WinForms oriented event model.
There is a learning curve to understand the why, when and how of ASP.NET MVC.
Lesser amount of code is required to build webapps since a lot of components are integrated and provided out of the box. You can also use a lot of data controls provided out of the box that rely on ViewState.
Since the application tasks are separated into different components, amount of code required is more. Since ASP.NET MVC does not use ViewState, you cannot use Data controls like GridView, Repeater.
Works very well for small teams where focus is on rapid application development
Works well for large projects where focus in on testability and maintainability

Monday 9 May, 2011

General Page Life-cycle Stages of ASP.NET

Stage

Description

Page request

The page request occurs before the page life cycle begins. When the page is requested by a

user, ASP.NET determines whether the page needs to be parsed and compiled or whether a

cached version of the page can be sent in response without running the page.

Start

In the start step, page properties such as Request and Response are set. At this stage, the page

also determines whether the request is a postback or a new request and sets the IsPostBack

property. Additionally, during the start step, the page's UICulture property is set.

Page

initialization

During page initialization, controls on the page are available and each control's UniqueID

property is set. Any themes are also applied to the page. If the current request is a postback,

the postback data has not yet been loaded and control property values have not been restored

to the values from view state.

Load

During load, if the current request is a postback, control properties are loaded with information

recovered from view state and control state.

Validation

During validation, the Validate method of all validator controls is called, which sets the IsValid

property of individual validator controls and of the page.

Postback event

handling

If the request is a postback, any event handlers are called.

Rendering

Before rendering, view state is saved for the page and all controls. During the rendering phase,

the page calls the Render method for each control, providing a text writer that writes its output

to the OutputStream of the page's Response property.

Unload

Unload is called after the page has been fully rendered, sent to the client, and is ready to be

discarded. At this point, page properties such as Response and Request are unloaded and any

ASP.NET caching (કેશીંગ)

તેમા ત્રણ પ્રકારના caching હોય છે.
Output caching (આઉટપુટ કેશિંગ)
Fragment caching(ફ્રેગમેન્ટ કેશિંગ)
Data caching(ડેટા કેશિંગ)

Output caching (આઉટપુટ કેશિંગ)
ડાયનેમિક રીતે બનેલા HTTP રીસ્પોંસનુ કેશીંગ
Fragment caching(ફ્રેગમેન્ટ કેશિંગ)
ડાયનેમિક રીતે બનેલા HTTP રીસ્પોંસનુ કોઈ ચોક્કસ ભાગનુ કેશિંગ
Data caching(ડેટા કેશિંગ)
સર્વરને મળતી HTTP રીક્વેસ્ટ મા પ્રોગામેટીકલી કોઈ ચોક્કસ ડેટાનુ કેશિંગ