user3107531
user3107531

Reputation: 85

HTML.Actionlink cannot resolve action in mvc

I have the following action link in my view

@Html.ActionLink("Our menu", "Index", "Menu", null)

As far as I understand it, it is supposed to point at the action Index from the controller Menu. However it does not see the MenuController which looks like:

namespace PizzeriaV2.Controllers
{
    public class MenuController : Controller
    {
        // GET: Menu
        public ActionResult Index()
        {
            DoSomething();
        }
    }
}

Instead of pointing at that action, the above mentioned link tries to look for Index in MainController - quite obviously not finding it there.

My questions are: Why is it happening? How can I make the link point at the right place?

Upvotes: 0

Views: 1375

Answers (1)

Amin Seifi
Amin Seifi

Reputation: 58

Use This Following Code :

@Html.ActionLink("Title","Index","Menu",null,null)

Or:

@Html.ActionLink("Title","Index","Menu")

Upvotes: 3

Related Questions