forum

Home / DeveloperSection / Forums / ASP MVC3 - ActionLink not routing to controller properly

ASP MVC3 - ActionLink not routing to controller properly

Samuel Fernandes 2141 05-Apr-2013
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 &&
                                       c.AgentId.Equals(compare)
                                 select c).Single();

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

http://localhost:2574/BankListMasterController/AgentEdit/11?agentId=5309721
I've also put a breakpoint in the first line of the method and it never gets tripped when debugging.

Thanks in advance! 


Updated on 05-Apr-2013

Can you answer this question?


Answer

1 Answers

Liked By