In view above error occured for @Model as Name 'Model' is not available in Current Context
I have created Model Movie.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace madtechtutor.Models
{
public class Movie
{
public int Id { get; set; }
public string Name { get; set; }
}
}
Created its Controller MoviesController:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using madtechtutor.Models;
namespace madtechtutor.Controllers
{
public class MoviesController : Controller
{
// GET: Movie
public ActionResult Random()
{
var movie = new Movie() { Name = "Avengers" };
return View(movie);
}
}
}
Created it's View Random.cshtml:
@model madtechtutor.Models.Movie
@{
ViewBag.Title = "Random";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>@Model</h2>