0

Facing problem while using "View data layout" So Please help me. Code are given below. Its showing redline on view data

public class Home1Controller : Controller
{

    [ViewData]

    public string Message { get; set; }

    public ActionResult Index()
    {
        Message = "Hello";

        return View();
    }
}
Yiyi You
  • 16,875
  • 1
  • 10
  • 22
  • The ViewDataAttribute class is in the Microsoft.AspNetCore.Mvc. It could be that you don't have using Microsoft.AspNetCore.Mvc; statement. Otherwise you can provide more details about the compiler error. "redline" is not enough information since it could be many things. The detailed compiler error would help others help you. – Sherif Elmetainy Oct 13 '21 at 22:11
  • 1
    what is the problem ? – IbraHim M. Nada Oct 14 '21 at 05:23
  • You need to make sure you are in a .net core project,refer to the official [doc](https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.mvc.controller.viewdata?view=aspnetcore-5.0) and check if you miss something. – Yiyi You Oct 14 '21 at 07:03
  • Thanks everyone – EHTISHAM AKRAM Oct 18 '21 at 19:32

0 Answers0