@using MvcSample.Web.Models @model User @{ Layout = "/Views/Shared/_Layout.cshtml"; ViewBag.Title = "Home Page"; string nullValue = null; ViewBag.Anon = new { Name = "FirstName LastName", Address = new { Street = "123 Fake St.", City = "Redmond", State = "WA", Country = "USA", }, }; } @functions { public async Task AsyncValueRetrieval() { return "Hello World"; } public Task RenderHelloWorldPartial(User model) { // Imagine this method was a super complex method that was used as a helper method. return Html.RenderPartialAsync("HelloWorldPartial", model); } }

ASP.NET

ASP.NET is a free web framework for building great Web sites and Web applications using HTML, CSS and JavaScript.

Learn more »

Hello @Model.Name! Happy @Model.Age birthday.

This value was retrieved asynchronously: @(await AsyncValueRetrieval())

Partial Async: @await Html.PartialAsync("HelloWorldPartial", Model)

Render Partial Async (Custom model): @{ await RenderHelloWorldPartial(new User() { Name="Bob" }); }

Getting started

ASP.NET MVC gives you a powerful, patterns-based way to build dynamic websites that enables a clean separation of concerns and gives you full control over markup for enjoyable, agile development.

Learn more »

Get more libraries

NuGet is a free Visual Studio extension that makes it easy to add, remove, and update libraries and tools in Visual Studio projects.

Learn more »

Web Hosting

You can easily find a web hosting company that offers the right mix of features and price for your applications.

Learn more »

'@Html.NameForModel()' '@Html.ValueForModel()'
'@Html.Name("Name")' '@Html.Value("Name")'
'@Html.NameFor(m => m.Address)' '@Html.ValueFor(m => m.Address)'
'@Html.Name("Anon.Address.Street")' '@Html.Value("Anon.Address.Street")'
@Html.TextBox("Name")
@Html.TextBoxFor(m => m.Address, htmlAttributes: new { @class = "form-control" })
@Html.TextBox("Anon.Name")
@Html.TextBox("Anon.Address.Street", (object)ViewBag.Anon.Address.Street)
@Html.TextBox("Anon.Address.City", value: null, format: "{0} (3)")
@Html.TextBox("Anon.Address.State", value: null, htmlAttributes: new { @class = "form-control" })
@Html.TextBox("Anon.Address.Country", value: null, format: "{0} (4)", htmlAttributes: new { @class = "form-control" })
@await Component.InvokeAsync("Tags", 15)