Showing posts with label Asp.Net. Show all posts
Showing posts with label Asp.Net. Show all posts

Monday, 22 April 2013

ViewModel in MVC


ViewModel is a complex object that may contain multiple entities or objects from different data models or data source.

ViewModel contain fields that are represented in the view (for LabelFor,EditorFor,DisplayFor helpers)
ViewModel can have specific validation rules using data annotations or IDataErrorInfo.
ViewModel can have multiple entities or objects from different data models or data source.

In ViewModel put only those fields/data that you want to display on the view/page.
Since view reperesents the properties of the ViewModel, hence it is easy for rendering and maintenance.
Use a mapper when ViewModel become more complex.

HTTP Handler Vs HTTP Module


HTTP Handler :
HTTP handlers are the .NET components that implement the System.Web.IHttpHandler interface. Any class that implements the IHttpHandler interface can act as a target for the incoming HTTP requests. HTTP handlers are somewhat similar to ISAPI extensions. One difference between HTTP handlers and ISAPI extensions is that HTTP handlers can be called directly by using their file name in the URL.

HttpHandler is a extension based processor.


HTTP Module :
Http modules are called before and after the http handler executes. Http modules enable developers to participate in, or modify each individual request. Http modules implement the IHttpModule interface, which is located in the System.Web namespace.

HttpModule is event based processor.

Tuesday, 9 April 2013

Bind vs Eval (Data Binder)


The data values can be retrieved with the Eval method – they cannot be modified or deleted.

The Bind method on the other hand allows for the data-bound controls to be modified in addition to retrieval, and hence is preferred over Eval method.