AspNetCore.Docs
AspNetCore.Docs copied to clipboard
First MVC App: ViewData["Title"] set but not used in the title-element
Description
- in "for" statement for the view, there is an ! mark just before the second semicolon. Please remove it.
- 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
Hello @n2ossareh ... The !
is present by design. It's a null-forgiving operator. https://learn.microsoft.com/dotnet/csharp/language-reference/operators/null-forgiving
I will briefly explain what the ! operator is doing there since this is a getting started tutorial and it is a relatively new feature.