How to pass information in Viewdata on Asp.net core MVC

Asked

Viewed 64 times

1

How to pass information (product name) from my controller Products to my Products view index by Viewdata?

1 answer

1


In the controller

public class ProdutosController : Controller
{
    public IActionResult Index()
    {
        ViewData["Informacao"] = "Alguma info";
        return View();
    }
}

In the view

<span>
    <p>@ViewData["Informacao"]</p>
</span>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.