You are on page 1of 5

Edward Hein

Post
Create
GET
Read
PUT
Update
DELETE Delete
http://www.youtube.com/watch?v=QpAhXa12xvU&feature=related
All UI validations should be done outside of the controller.
ASP.NET MVC supports 4 types of filter.
Before the action is executed, after -> Action Filters
Before the result is processed, after -> Result Filter
Exception Filter
Authorization Filter
Filters implement chain of responsibility pattern. In what ever order the filter
s are added, thay are
executed in the same order. This is like a pipe line based processing. One's out
put is the input to other
Logging is supported in Action Filter

Investment proof
Backbone to MVC is routing.
URL rewriting and routing difference?
Because it is GET enabled, it is REST enabled, SEO supported
Static table is provided by MVC called RouteTable. RoutingReistry. ASP.NET adds
an entry to this registry
Routes is a static property on RouteTable static class.
Routing APIs support is given only in IIS7 and upwards.
Representational State Trasfer. A mechanism of accessing resources from server a
s a URL.
You can unit test the controller itself. MVC is unit testable. UI components can
also be unit tested.
With MVC there is better control over HTML rendered to the browser. Thus can be
optimized for browsers.
Easy to leverage HTML 5
JQuery, YUI, AmazonUI
JQuery will be used for Ajax from client side in MVC
There is no concept like controls. There is no events or viewstate in MVC. There
is no life cycle.
Partial View is the equivalent for re-usable components.
A layout page is similar to the master page. The names have changed because you
will apply the old things
also the same way in the new MVC approach.

There is a method called RenderHTML (provide partial view)


A layout has to be chosen at runtime. That way we can change the layout based on
geographics
There are options to create layout and content pages
Support for strongly typed views. If the view is aware of the model, then it is
called Strongly Typed View support
HTMLHelpers are to be used as much as possible. We can extend them also
AjaxHelper, URLHelper are supported by MVC
Non-functional capabilities can be added to the controllers using filters
All UI validations should be done outside of the controller.
ASP.NET MVC supports 4 types of filter.
Before the action is executed, after -> Action Filters
Before the result is processed, after -> Result Filter
Exception Filter
Authorization Filter
Filters implement chain of responsibility pattern. In what ever order the filter
s are added, thay are
executed in the same order. This is like a pipe line based processing. One's out
put is the input to other
Logging is supported in Action Filter
Security Support - Membership and Role provider can be leveraged for authenticat
ion and authorization in MVC
A controller checks the validity of the model using IsModelValid
Model validation support. Server side/ Client side
ValueProvider, Model Binder, RouteData, FormInput Data, SOAP components are used
for preparing the model
from request object. We can come with a provider for preparing the model also
Able to extend anything. Customization is easy. Plugability is easy
We can also write our own view engine.
By default MVC uses reflection to create an instance of the controller. We can b
uild our own controller factory
MVC controller is stateles (no session)
C# 4.0 uses a new feature called "Dynamic". In this compiler does not infer the
type during compilation.
ViewData is a dictionary that can be used in controller and view.
ViewBag is the new data dictionary given in MVC 3
ViewBag.Name = "ABCD". This is the way to use it.
For every request ViewData or viewbag Context is created. that means viewdata di
ctionary is created.
If a controller's action redirects to another controller and another action, the
n the view data or viewbag created by the first controller is lost.

TempData is a new feature with MVC3. This uses the session itself but the object
is marked for deletion when the data is retrieved. There is a provison
to keep the data. This has to be done explicitly. Need to research.
You can customize this tempdata using customdataprovider.
MVC 3 takes advantage of Dependency Injection and IoC using a component called D
ependency Resolver. This is required because if a controller has to be passed
a certain type (like Interface) then there should be some way to associate the i
nterface implementing class which is done by IoC.
ChildAction - Calling a controller from a view is called ChildAction
ChildActionOutput Cacheing is supported by MVC3. This is the fragment cacheing.
That means part of the output from a view can be cached.
MVC3 has a new type of validation called RemoteValidation. In this a JQuery is s
ent to the client which will call the server side controller's action method.
Ex. To test if the customer id entered by the user exists in the database or not
. (This is JQuery enabled server side validation)
There is a new concept called ModelMetaData provider in MVC3. This supports addi
ng dynamic extra information to models.
MVC3 provides a new library called Anti XSS Library. In this you can only encode
the javascript/vbscript / HTML
Cross Site Request Forgery (CSRF): Example. Take the form information (where the
submit happens) from some other site and
create a small JS code and submit it in a loop. This can be prevented in MVC3 ba
sed on tokens.
AntiForgeryToken is a new feature in MVC3 to prevent CSRF (Cross Site Request Fo
rgery attacks).
GlobalFilters Filter provider. This helps to add general purpose filter to all c
ontroller actions.
GlobalFilters are available in global.asax.cs file inside RegisterGlobalFilters
method
FilterProvider support to choose filters at runtime.
NuGet is a new feature in MVC3. This can get updated version of the components.
NuGet deployment support is provided with MVC3.
Front controller calls the controller activator which uses reflection to create
an instance of our controller
by passing the context of the request object.
_ViewStart.cshtml has all the details about how to apply the default layout for
all the views
By Default razor views are compiled into classes that inherit from System.Web.Mv
c.WebViewPage. This is visible from web.config located inside views folder
_Layout.cshtml file has the layout to follow for all the view pages. Error.cshtm
l is used for displaying any errors that occure during page execution
Packages.config: This file is located at the project level.
When ever we aded NuGet reference then that entry is added in the packages.confi
g file.

If your class is inheriting from IController, then it is called CustomController


. Or it can inherit from controller class
All the public non-static methods in the controller are callable from the browse
r. If you
want a public method but cannot be called then it has to be decorated with
[NonAction]
If we add the attribute ActionName = "ABCD" to a public non static method inside
a controller class,
then that method has to be called as ABCD only and not the exact method name.
There are two types of action result. (1) ViewResult (2) Non-ViewResult. Produci
ng JSON output is a non view result

--------------- 2nd time hearing to video tutorial


default() - to be understood
scafolding - to be understood
Best practices
How to have sub folders inside areas. One way is to remove the constraint inside
the web.config
urlhelper
htmlhelper
ajaxhelper
viewhelper
Filters are used for adding non-functional features like Authorization, security
, logging etc.
MVC supports 4 types of filters.
1. Before the action is executed
2. Post the action has occurred
Action Filters
Result Filters
Exception Filters
Authorization Filters
Filters implement the chain of responsibility pattern
To support logging we have to use Action Filter.
Membership provider and Role provider can be leveraged as is in ASP.NET MVC
ValueProvider, ModelBinder -- These components are used for preparing the model
from the collection
Asynchronous Controllers are like ajax on the server side. They give back the as
p.net thread and
works in the background thread
ModelMetaData - This is like adding additional information like validation to th
e model class

ViewTemplate for the models


ChildAction is for displaying some other controller's action method in another c
ontrollers's
view
Output and fragment cacheing are supported in controllers and actions
Cross Site scripting/ simplified html encoding
web.config transformations
How would deploy a MVC application
Unique features of MVC 3
----------------------Razor view
Session Stateless controller
Dynamic programming - Compiler does not worry about the type
ViewBag is a dynamic object
TempData - When the data is read from this structure, then the data is deleted.
For performing ChildAction, we can save the data from controller1, action1 and
access it in controller2, action2
Custom TempData provider
Dependency Resolver will be used with IoC and Dependency Injection
Fragment cacheing is supported. It is called ChildAction Output cacheing support
Remote Validation -- To generate some JQuery that would call some other controll
er's action
(Ajax enabled server side validation)
ModelMetaData Provider
Anti XSS Library
(Encode only vbscript, only javascript etc.)
Global Filters Filter Provider - This would apply to all the controllers' action
s
Filter Providers support to choose filtes at runtime
nuGet Support (minifier is a package for js minification)
ControllerActivator -- Uses reflection to create our controller. This passes a c
ontext called
controllercontext as a property. So we can call this in out controller like
this.Context.Current etc.