- With ViewBag (dynamic type):
- Action: ViewBag.Message = "Hello World!";
- View: @ViewBag.Message
- With ViewData (dictionary)
- Action: ViewData["message"] = "Hello World!";
- View: @ViewData["message"]
- With Strongly-typed views:
- Action: return View(model);
- View: @model ModelDataType;
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>Document</title> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous"> | |
<style> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dynamic person = new object { Name = "John", Age = 32, Title = "HR" }; | |
// In case the person comes from somewhere else | |
if (person != null) | |
{ | |
var properties = person.GetType().GetPtoperties(); // Will return an Array of System.Reflection.PropertyInfo[]; | |
// or | |
Type theType = (Type)person.GetType(); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string text = System.Threading.Tasks.Task.Run(() => "TEXT".ToLower()).GetAwaiter().GetResult(); | |
// To retreive the result it bloks the other code. | |
// https://www.youtube.com/watch?v=fX62PJ_wv20 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var taskArray = new Task[tasksCount]; | |
for (int index = 0; index < taskArray.Length; index++) | |
{ | |
var productId = productIds[index]; | |
var task = Task.Run(() => UpdatePoductStatus(productId, Status.Available)); | |
taskArray[index] = task; | |
} | |
Task.WaitAll(taskArray); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
This script will work only on the client-side | |
*/ | |
function toClientDate(dateText) { | |
if (!validateInput(dateText)) { | |
return ''; | |
} | |
var date = new Date(dateText); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
return | |
<First_Expression> ? "Value1" : | |
<Second_Expression> ? "Value2" : | |
<Third_Expression> ? "Value3": | |
"Value4"; // And so on.... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public event EventHandler AuthenticateRequest | |
{ | |
add | |
{ | |
this.AddSyncEventHookup(HttpApplication.EventAuthenticateRequest, value, RequestNotification.AuthenticateRequest); | |
} | |
remove | |
{ | |
this.RemoveSyncEventHookup(HttpApplication.EventAuthenticateRequest, value, RequestNotification.AuthenticateRequest); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Extracted from System.Web | |
public IPrincipal User | |
{ | |
get | |
{ | |
return this._principalContainer.Principal; | |
} | |
[SecurityPermission(SecurityAction.Demand, ControlPrincipal=true)] | |
set | |
{ |