Shahid Iqbal
Shahid Iqbal

Reputation: 2135

Route(URL) error for each controller

I am new to ASP.Net MVC 4. I have 2 controllers

each controller have a menu CustomerSetup and SupplierSetup.

The first visited menu is ok, e.g when i click on CustomerSetup Menu, url looks like localhost:1496/Customer/Index its ok, now when i click on Supplier Menu, url looks like localhost:1496/Customer/Supplier/Index instead of localhost:1496/Supplier/Index and below error is shown..

Server Error in '/' Application.
The resource cannot be found.

Upvotes: 0

Views: 77

Answers (2)

Brajesh
Brajesh

Reputation: 451

I think using html helper can help:

 @Html.ActionLink("Menu name(display to user)","Action_name","Controller_name")

This will take you to your desired controller action. eg:

@Html.ActionLink("Home","Index","Home")

Upvotes: 0

haim770
haim770

Reputation: 49133

The problem is probably because you're using hand-coded URL to point to your Supplier.Index action. You better use the Url.Action() method instead:

<a href="@Url.Action("Index", "Supplier")">Supplier Menu</a>

See Documentation

Upvotes: 1

Related Questions