AspNetCore.Docs icon indicating copy to clipboard operation
AspNetCore.Docs copied to clipboard

First MVC App: ViewData["Title"] set but not used in the title-element

Open n2ossareh opened this issue 1 year ago • 2 comments

Description

  1. in "for" statement for the view, there is an ! mark just before the second semicolon. Please remove it.
  2. The ViewData["Title"] is set to "Welcome", but it has not been used in the title-element. Instead the hardcoded string "Welcome" has been re-used. Please change the Title element to @ ViewData["Title"] .

Page URL

https://learn.microsoft.com/en-us/aspnet/core/tutorials/first-mvc-app/adding-view?view=aspnetcore-8.0&tabs=visual-studio

Content source URL

https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/tutorials/first-mvc-app/adding-view.md

Document ID

00c2c01d-d235-2d2d-5c96-1f33a9314382

Article author

@wadepickett

n2ossareh avatar Dec 08 '23 03:12 n2ossareh

Hello @n2ossareh ... The ! is present by design. It's a null-forgiving operator. https://learn.microsoft.com/dotnet/csharp/language-reference/operators/null-forgiving

guardrex avatar Dec 08 '23 11:12 guardrex

I will briefly explain what the ! operator is doing there since this is a getting started tutorial and it is a relatively new feature.

wadepickett avatar Jan 29 '24 23:01 wadepickett