Format Razor example in overview as cshtml (#13383)

pull/13600/head
Jacob Bundgaard 2019-08-01 13:49:51 +02:00 committed by Luke Latham
parent 4f95255249
commit 79a08f56bc
1 changed files with 12 additions and 11 deletions

View File

@ -3,7 +3,7 @@ title: Overview of ASP.NET Core MVC
author: ardalis
description: Learn how ASP.NET Core MVC is a rich framework for building web apps and APIs using the Model-View-Controller design pattern.
ms.author: riande
ms.date: 01/08/2018
ms.date: 08/01/2019
uid: mvc/overview
---
# Overview of ASP.NET Core MVC
@ -82,11 +82,11 @@ routes.MapRoute(name: "Default", template: "{controller=Home}/{action=Index}/{id
[Route("api/[controller]")]
public class ProductsController : Controller
{
[HttpGet("{id}")]
public IActionResult GetProduct(int id)
{
...
}
[HttpGet("{id}")]
public IActionResult GetProduct(int id)
{
...
}
}
```
@ -96,7 +96,7 @@ ASP.NET Core MVC [model binding](models/model-binding.md) converts client reques
```csharp
public async Task<IActionResult> Login(LoginViewModel model, string returnUrl = null) { ... }
```
```
### Model validation
@ -143,6 +143,7 @@ Your app can also use [dependency injection in view files](views/dependency-inje
```cshtml
@inject SomeService ServiceName
<!DOCTYPE html>
<html lang="en">
<head>
@ -183,11 +184,11 @@ The framework's use of interfaces and dependency injection make it well-suited t
[ASP.NET Core MVC views](views/overview.md) use the [Razor view engine](views/razor.md) to render views. Razor is a compact, expressive and fluid template markup language for defining views using embedded C# code. Razor is used to dynamically generate web content on the server. You can cleanly mix server code with client side content and code.
```text
```cshtml
<ul>
@for (int i = 0; i < 5; i++) {
<li>List item @i</li>
}
@for (int i = 0; i < 5; i++) {
<li>List item @i</li>
}
</ul>
```