ASP.net MVC Visual studio 404 error page

0
26

I am beginner student learning on mvc-5 web application using visual studio 2017.
working on assignment need to create page that has a Customer in the header , when I l click on it , 2 customers name will appear each with a different ID hyper link.
whenever I Build and run the project 404 error page appears.
if anyone can help I’ve been searching for hours . thank you in advanced .

below are my controllers , views .

Controller for Customers :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using VIDLY.Models;
namespace VIDLY.Controllers
{
    public class CustomersController : Controller

    {

        public ViewResult Index()

        {

            var customers = GetCustomers();



            return View(customers);

        }



        public ActionResult Details(int id)

        {

            var customer = GetCustomers().SingleOrDefault(c => c.Id == id);





            return View(customer);

        }



        private IEnumerable<Customers> GetCustomers()

        {

            return new List<Customers>

            {

                new Customers { Id = 1, Name = "John Smith" },

                new Customers { Id = 2, Name = "Mary Williams" }

            };

        }

    }

}

I have two Views : index and Details
Index for customers :

@model IEnumerable<VIDLY.Models.Customers>



@{

    ViewBag.Title = "Customers";

    Layout = "~/Views/Shared/_Layout.cshtml";

}
<h2>Customers</h2>

@if (!Model.Any())

{

    <p>We don't have any customers yet.</p>

}

else

{

    <table class="table table-bordered table-hover">

        <thead>

            <tr>

                <th>Customer</th>

            </tr>

        </thead>

        <tbody>

            @foreach (var customer in Model)

            {

                <tr> 

                    <td>@Html.ActionLink(customer.Name, "Details", "Customer", new { id = customer.Id }, null)</td>

                </tr>

            }

        </tbody>

    </table>

}

details for customers :

@model VIDLY.Models.Customers
@{

    ViewBag.Title = "Customer";

    Layout = "~/Views/Shared/_Layout.cshtml";

}

<h2>@Model.Name</h2>

Customer model :

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

namespace VIDLY.Models
{
    public class Customers
    {
        public int Id { get; set; }
        public string Name { get; set; }
    }
}

I have another Shared View I called it _navbar for the _layout navbar :

<div class="navbar navbar-inverse navbar-fixed-top">

    <div class="container">

        <div class="navbar-header">

            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">

                <span class="icon-bar"></span>

                <span class="icon-bar"></span>

                <span class="icon-bar"></span>

            </button>




            @Html.ActionLink("Vidly", "Index", "Home", new { area = "" }, new { @class = "navbar-brand" })



        </div>



        <div class="navbar-collapse collapse">



            <ul class="nav navbar-nav">






                <li>@Html.ActionLink("Customer", "Index", "Customer")</li>



                <li>@Html.ActionLink("Movies", "Index", "Movies")</li>



            </ul>


        </div>
    </div>
</div>

LEAVE A REPLY

Please enter your comment!
Please enter your name here