Hola.
Soy nueva en MVC.
Me aparece este error y no consigo resolverlo les agradeceria su ayuda, mi codigo es el siguiente.
Nota: Trato de mostrar una listado del menu
Model.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Restaurant.Models
{
public class Menu
{
public int Id { get; set; }
public string Categoria { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public int Precio { get; set; }
}
}
MenuController
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Restaurant.Models;
namespace Restaurant.Controllers
{
public class MenuController : Controller
{
// GET: Menu
public ActionResult Index()
{
List<Menu> menu = new List<Menu>();
menu.Add(new Menu { Id = 1, Categoria = "Desayuno", Name = "omelet", Description = "Jamon,Queso,Papas", Precio = 10 });
menu.Add(new Menu { Id = 2, Categoria = "Bebidas", Name = "Cafe", Description = "Crema o canela", Precio = 6 });
menu.Add(new Menu { Id = 3, Categoria = "Postres", Name = "Flan Napolitano", Description = "Vainilla,Nuez,Cafe", Precio = 15 });
menu.Add(new Menu { Id = 4, Categoria = "Comida", Name = "Flautas", Description = "Queso,Papa,Chorizo", Precio = 25 });
menu.Add(new Menu { Id = 5, Categoria = "Ensaladas", Name = "Romana", Description = "Zanahoria,Lechuga,berros,vinagre", Precio = 34 });
return View(menu);
}
}
}
Vista Index
@model Restaurant.Models.Menu
@{
ViewBag.Title = "Index";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>Menu</h2>
<table>
<thead>
<tr>menu de hoy</tr>
</thead>
<tbody>
<tr>
<td>Categoria</td>
<td>@Model.Categoria</td>
</tr>
<tr>
<td>Name</td>
<td>@Model.Name</td>
</tr>
<tr>
<td>Desciption</td>
<td>@Model.Description</td>
</tr>
<tr>
<td>Precio</td>
<td>@Model.Precio</td>
</tr>
</tbody>
</table>