0

I'm working on a ASP.NET web app and the ViewBag, Layout and Model all say The name ViewBag/ Layout/ Model does not exist in current context.

I have seen some solutions for this problem for Microsoft Visual Studio, but I can't find any for Macs.

Does anyone know a solution for this problem in Mac?

I have attached a picture and also written the code out below.

Thank you

@model WebApp.Models.Movie

@{ ViewBag.Title = "Random"; // Read line under ViewBag here Layout = "~/Views/Shared/_Layout.cshtml"; // Red line under the first Layout here }

<h2>@Model.Name</h2> // Red Line under Model here

  • hi, Sometimes visual studio shows red lines in cshtml, which may appear as error but thats ok. Try running your application and see if it throws any exception. Also your question " to get ViewBag, Layout and Model in context" is not very clear, so be specific. – Gambitier Jun 04 '20 at 13:36
  • Try these answers: https://stackoverflow.com/questions/19696963/razor-view-throwing-the-name-model-does-not-exist-in-the-current-context – Steve Greene Jun 04 '20 at 15:06

0 Answers0