Show Menu
Cheatography

Dot Net Cheat Sheet Cheat Sheet (DRAFT) by

for school purposes...

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Asynch­ronous JavaScript & XML (AJAX)

Technique for accessing web servers from a web page.
Modifies only a portion of the displayed page without the need to reload the whole document file
Enables more intera­ctivity not possible in the tradit­ional web applic­ations using synchr­onous request and response model

Partial Page Update

A mark up file (.cshtml) that renders HTML output wihtin another markup file's rendered output
In contro­ller: return­(Pa­rti­alView ("_v­iew­Pag­e", model());
In .cshtml: <pa­rtial name = "­_vi­ewP­age­" model = ("codes in here")

Web API

REST APIs
- Stands for REpresen­tat­ional State Transwer
- Operats on HTTP reques­t/R­esponse Protocol
HTTP Status Code
- Sucessful Responses: 200, 201
- Redire­ction Response: 301
- Client Error: 400, 401, 403, 404
- Server Error: 500
API returning object with HTTP Status
- IActio­nResult return type like Web App controller
- Able to be return with HTTP response status:
Ok(200)
NotFound(404
BadRequest(400)
UnAuthorized(401)
Media Format Support in WEB API
- XML (eXten­sible Markup Language)
- JSON(J­ava­Script Object Notation)
- BSON(B­inary JSON)
Web API Routing
- Routing maps incoming requests to specific controller and action
Example:
In ApiCon­tro­ller:
 [Route­("ap­i/(name of contro­lle­r)")]

In Browser: http:/­/lo­cal­hos­t/a­pi/­con­troller
 

jQuery

load() - method is used to load data from a server and puts the returned data into the selected element.
Syntax:
$(selector).load(URL)
$(sele­cto­r).l­oa­d(URL, data, callback)
getJSON() - method used to get JSON data using an AJAX HTTP GET request
Syntax:
$(selector).getJSON(url,data,success(data,status,xhr)
Example:
$.getJ­SON­("bo­ok.j­son, function (result)) {$("­#aa­a").h­tm­l(r­esu­lt.t­itle);
append() - method to insert specified content at the end of the selected elements. Use prepend() to insert content at the beginning.
Syntax:
$(selector).append(content)
each() - method to iterate over DOM elements, arrays and objects.
Syntax
$(selector).each(function(index, value))
$.each(collection, functi­on(­index, value))
serail­ize() - method to create a URL encoded text string by serial­izing form values.
Syntax
$(selector).seralize()
ajax() - method which provides core functi­onality of AJAX
Syntax:
$.ajax(url)
$.ajax(url, [options])

Promises in JavaScript

Represents the eventual completion of an asynch­ronous operation and its resulting value
Examples of 3 methods for handling promises:
-done()
-fail()
-always()
 

JSON

Data Types
- Number
- String
- Boolean
- Object
- Array
- null
Objects
- JSON objects are dictionaries.
- Enclosed with curly brackets { }
- Keys and Values can be any data type
Arrays
- Arrays are Lists
- Enclosed with square brackets { }
- In between, a list of values separated by commas.
- Each of which ma be of any type.
Nesting
- Nesting Involves putting arrays and objects inside each other
- Arrays can be put inside objects, objects inside arrays, and so on.
- A JSON file can be one BIG object with lots of objects and arrays inside

Promises in JavaScript

Represents the eventual completion of an asynch­ronous operation and its resulting value
Examples of 3 methods for handling promises:
-done()
-fail()
-always()

Web API

REST APIs
- Stands for REpresen­tat­ional State Transwer
- Operats on HTTP reques­t/R­esponse Protocol
HTTP Status Code
- Sucessful Responses: 200, 201
- Redire­ction Response: 301
- Client Error: 400, 401, 403, 404
- Server Error: 500

Web API

REST APIs
- Stands for REpresen­tat­ional State Transwer
- Operats on HTTP reques­t/R­esponse Protocol
HTTP Status Code
- Sucessful Responses: 200, 201
- Redire­ction Response: 301
- Client Error: 400, 401, 403, 404
- Server Error: 500