I am getting error : The type name 'Models' does not exist in the type 'System.Web.Helpers.Chart'
Please help me in resolving this. Here is the code developed with mvc and razor syntax:
Model
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace Chart.Models
{
public class FooBarModel
{
public IEnumerable<SelectListItem> Locations { get; set; }
}
}
Controller:
using Chart.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace Chart.Controllers
{
public class FooController : Controller
{
//
// GET: /Foo/
public ActionResult Index()
{
var locations = new[]
{
new SelectListItem { Value = "US", Text = "United States" },
new SelectListItem { Value = "CA", Text = "Canada" },
new SelectListItem { Value = "MX", Text = "Mexico" },
};
var model = new FooBarModel
{
Locations = locations,
};
return View(model);
}
}
}
View Code:
@model Chart.Models.FooBarModel // intellisense shows error on this line as well
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>
<script>
var locations = @Html.Raw(Json.Encode(Model.Locations));
</script>
</head>
<body>
<div>
</div>
</body>
</html>