简体   繁体   中英

The Resource cannot be found error in ASP.Net

Server Error in '/' Application. The resource cannot be found. Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.

Requested URL: /Movies/Random

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.3928.0

This is an Error Message Shown when I Started doing an online tutorial. What may be the reason for this???

Random.cshtml

@model Vidly.Models.Movie
 @{
ViewBag.Title = "Random";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>@Model.Name</h2>

Movie.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Vidly.Models
{
    public class Movie
    {
    public int Id { get; set; }
    public string Name { get; set; }
    }
}

MoviesController.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Vidly.Models;

namespace Vidly.Controllers
{
    public class MoviesController : Controller
    {
        // GET: Movies/Random
        public ActionResult Index()
        {
            var movie = new Movie() { Name = "Hello" };

            return View(movie);
        }
    }
}

In the MoviesController.cs it should be

public ActionResult Random()

instead of

public ActionResult Index()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM