why i can not access new product List from MVC?

Hi! i try to learn Asp.net MVC.i created a sample application to learn it. But press f5 return server error. Where do l make a mistake? where is the problem? there is a navigator bar Home/About/Product . if i press Product, error return to me.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MvcApplication1.Models.Db;

namespace MvcApplication1.Controllers
    public class ProductsController : Controller
        // GET: /Products/

        public ActionResult GetAll()
            using (var ctx = new MyDbEntities())
                ViewData["Products"] = ctx.Products;
                return View();



Open in new window


<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<MvcApplication1.Models.Db.Product>" %>
<%@ Import Namespace="MvcApplication1.Models.Db" %>
<%@ Import Namespace="MvcApplication1.Controllers" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">


<% foreach (var m in (IEnumerable<Products>)ViewData["Products"])
     { %>

     <li><%= m.ProductName %></li>

<% } %>


Open in new window

            <div id="menucontainer">

                <ul id="menu">              
                    <li><%: Html.ActionLink("Home", "Index", "Home")%></li>
                    <li><%: Html.ActionLink("About", "About", "Home")%></li>
                     <li><%: Html.ActionLink("Product", "ProductDetail", "Product")%></li>


Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

That is because your link contains the wrong action.  Either add an action to your controller to match the action your asking for on your view HTML.ActionLink or adjust the actionlink to match your controller action.  If you modified your view it would you HTML.ActionLink would look like this:

<li><%: Html.ActionLink("Product", "GetAll", "Product")%></li>

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.