Home > DeveloperSection > Forums > ASP MVC3 - ActionLink not routing to controller properly
Samuel Fernandes
Samuel Fernandes

Total Post:159

Posted on    April-05-2013 1:35 AM


 1 Reply(s)
 1211  View(s)
Rate this:
Hi Everyone!

Below is the action link I'm using in an ASP MVC3 view. I need to a method in the controller and send in two variables. These variables serve as the 

compound key on a SQL table that the controller method is trying to pull information from.

The link appears to be rendered properly by the @Html.ActionLink, however I am getting this error:

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: /BankListMasterController/AgentEdit/11

Here is the action link

@Html.ActionLink("Edit Agent", "AgentEdit", "BankListMasterController",
                                            new { agentId = int.Parse(item.AgentId), id = item.ID }, null)
Here is the controller method

    public ViewResult AgentEdit(int id, int agentId)
        string compare = agentId.ToString();

        BankListAgentId agent = (from c in db.BankListAgentId
                                 where c.ID == id &&
                                 select c).Single();

        return View("AgentEdit", agent);
and here is the URL that is rendered in the original view

I've also put a breakpoint in the first line of the method and it never gets tripped when debugging.

Thanks in advance! 


Total Post:604

Posted on    April-05-2013 8:03 AM

Hi Samuel!

You can try this way

include "controller" name in the third parameter.

@Html.ActionLink("Edit Agent", "AgentEdit", "BankListMaster", new { agentId = int.Parse(item.AgentId), id = item.ID }, null)

Don't want to miss updates? Please click the below button!

Follow MindStick