Search code examples
c#asp.net-mvcasp.net-mvc-2actionlinkhtml.actionlink

ASP .Net MVC site.master HTML.ActionLink new menu item set


Just started MVC 2.0. There are built in views. In home there are two view. Index.aspx and about.aspx. I am creating a new folder in Views named customer and create a new page "Customer.aspx" with some text to show. Menu item is created but not going into the page.

Here what i am trying.

<div id="menucontainer">

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

is the code alright?

The Error is :


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: /Customer/CustomerDataAdd


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


Solution

  • You will need to create a new Controller class called Customer with a method called CustomerDataAdd that will return the newly created CustomerDataAdd view.

    public class Customer : Controller
    {
        public ActionResult CustomerDataAdd()
        {
            return View();
        }
    }