// model
public class LogonModel
{
[Required]
public string Username { get; set; }
}
// widoku
@Html.TextBoxFor( m => m.Username )
@Html.ValidationMessageFor( m => m.Username )
// do tego css
.field-validation-error {
display : none;
}
.input-validation-error {
border : 1px solid red;
background-color : cornsilk;
}
(lista kolorów predefiniowanych w CSS)
// synchroniczne
public ActionResult Foo()
{
var result = Method();
return Content( result );
}
// asynchroniczne
public async Task<ActionResult> Foo()
{
var result = await MethodAsync(); // uwolnienie wątka roboczego
return Content( result );
}
// widoku @Html.AntiForgeryToken(); // w kontrolerze [HttpPost] [ValidateAntiForgery] public async TaskBar() { ... }