I am using _ViewData_ attribute to display its value on _View_ using _Model_.
Here is the code from my controller file:
` public class HomeController : Controller
{
[ViewData]
public string Title { get; set; }
public ViewResult Index()
{
Title = "Home page title";
return View();
}
}`
Now as per the documentation , there are two ways to display this data on view file.
<h1>@ViewData["Title"]</h1>Using this approach data gets displayed on view.
<h1>@Model.Title</h1>Here is the error:
RuntimeBinderException: Cannot perform runtime binding on a null reference
And as per my understanding, this error is correct as we are not passing data as a Model.
second, suppose I am already using strongly type binding on view and along with this I want to use ViewData attribute. Now if I display the ViewData value using @ Model.Property then I will get compile-time error.
I find a similar issue here. This issue is closed without any valid answer. I believe this is a wrong explanation on the document. Kindly clarify.
Asp.Net Core MVC 3.1
⚠Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
I have tried with _Visual Studio 2019 & DotNet CLI_. In both the cases, I am getting the same error.
next time Can you create an issue from the doc page? That will connect the doc to the issue. Go to the bottom of the page and select This page .

I've had a look into this, running up some examples and looking through the source. I get the same result as @nitishwebgentle, and it makes sense. I suggest we drop the @Model.Title example from the topic.
Most helpful comment
I've had a look into this, running up some examples and looking through the source. I get the same result as @nitishwebgentle, and it makes sense. I suggest we drop the
@Model.Titleexample from the topic.