MVC:
3 Things needs to specify route
1. URL Pattern: can include placeholder in URL pattern so that variable data can be passed to request handler without requiring query string
2. Handler: can be physical file (.aspx) or controller class
3. Name for Route: Name is optional.
Levels at which filters can applied
1. Action Method
2. Controller
3. Application
Start of code Block in Razor view: @
Start of code Block in ASPX view: ;
Extensions of Razor view:
.cshtml – for C#
.vbhtml – for VB
Comments using Razor syntax:
* This is a Comment * @
NHibernate can:
- Send multiple updates / inserts / delete at once
- Load multiple proxies of a type at once
- Load multiple collections of a type at once
- Execute object oriented DML statements
- Manually group queries in a single round trip
- Entity Framework does nothing from above.
Explain MVC:
M (Model) – part of code that known things
V (View) – part of code that shows things the model knows
C (Controller) – part of code that gets commands from User and tells the view what to show and he Model what to know.
e.g. TV – Channal Cable provider (Model)
- Screen Display (View)
- Remote Buttons (Controller)
Reduce Load time of Web Application Tips:
1. Use “css- based image sprites”, instead of multiple images to reduce HTTP request
2. Rely on Robust CSS
3. Minimize all javascript files (using tool jscompress.com) to reduce the amount of data transferred.
4. Combine external javascript files to reduce HTTP requests.
5. Watch application load using tool “YSlow” or Webskit’s resources inspector to identify and bottleneck.
6. Analyse database queries and javascript functions.
Types of Filters in MVC:
1. Authrization – i.e. Require HTTP Attribute, Authorize attribute, sequence to follow
2. Action –
3. Result – i.e. Output Cache Attribute
4. Exception
Role of controller in MVC Application:
- Controller responds to user interactions, with the application, by selecting action method to execute and also selecting the view to render.
Return Types of Controller action method
1. View Result
2. JavaScript Result
3. Redirect Result
4. Content Result
5. Json Result
3 Segments of default Route, in MVC Application
1. 1st Segment – Controller Name. i.e. Customer
2. 2nd Segment – Action Method Name. i.e. Details
3. 3rd Segment – Parameter that is passed to Action method. I.e. 5
i.e. http://Shree.com/customer/details/5
Settings for routing work, where?
1. Web.config – ASP.Net routing has to be enable here
2. Global.asax – Route table is created in application, start event handler, of global.asax file.
MVC Framework folder structure
1. App_Data: contains database files
2. Content: contains static content for web application.
i.e. css, images, et.
3. Controller: contains controller classes that use Architecture.
4. Models: consist of the model classes that are used to interact with content and go in sync with MVC Architecture of ASP.Net
5. Scripts: JavaScript files that include AJAX library and JQuery script files.
6. Views: contains frontend view that will be seen after model is rendered.
Page Lifecycle of MVC
1. Application Initialization
2. Routing
3. Instantiate and Execute Controller
4. Locate and Invoke controller action
5. Instantiate and Render view
Create Dynamic Property with ViewBag
List (string)countries = new List (string)();
Contries.Add (“India”);
Contries.Add(“USA”);
ViewBag.Countries = countries;
• A country is dynamic property.