Http Status Codes
- 200 OK
- 201 Created
- 204 No Content
- 304 Not Modified
- 400 Bad Request
- 401 Unauthorized
- 403 Forbidden
- 404 Not Found
- 409 Conflict
- 500 Internal Server Error
- 501 Not Implemented
- 502 Bad Gateway
- 503 Service Unavailable.
| Single() | SingleOrDefault() | First() | FirstOrDefault() | |
|---|---|---|---|---|
| Description | Returns a single, specific element of a sequence | Returns a single, specific element of a sequence, or a default value if that element is not found | Returns the first element of a sequence | Returns the first element of a sequence, or a default value if no element is found |
| Exception thrown when | There are 0 or more than 1 elements in the result | There is more than one element in the result | There are no elements in the result | Only if the source is null (they all do this) |
| When to use | If exactly 1 element is expected; not 0 or more than 1 | When 0 or 1 elements are expected | When more than 1 element is expected and you want only the first | When more than 1 element is expected and you want only the first. Also it is ok for the result to be empty |
IndexOf or StartsWith. You'll have to convert the StringBuilder object to a String for these operations, and this can negate the performance benefit from using StringBuilder.Consider using the StringBuilder class under these conditions:
When you expect your code to make an unknown number of changes to a string at design time (for example, when you are using a loop to concatenate a random number of strings that contain user input).
When you expect your code to make a significant number of changes to a string.
Console.WriteLine(Math.Round(6.5)); => 6 Console.WriteLine(Math.Round(11.5)); => 12
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 (therefore beginning the life of a page), or whether a cached version of the page can be sent in response without running the page.
|
Start
|
In the start stage, 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. The page also sets the UICulture property.
|
Initialization
|
During page initialization, controls on the page are available and each control's UniqueID property is set. A master page and themes are also applied to the page if applicable. 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.
|
Postback event handling
|
If the request is a postback, control event handlers are called. After that, the Validate method of all validator controls is called, which sets the IsValid property of individual validator controls and of the page. (There is an exception to this sequence: the handler for the event that caused validation is called after validation.)
|
Rendering
|
Before rendering, view state is saved for the page and all controls. During the rendering stage, the page calls the Render method for each control, providing a text writer that writes its output to the OutputStream object of the page's Response property.
|
Unload
|