• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 337
  • Last Modified:

Trouble finding where a Controller Action is being called

I have worked on MVC3 before. But am having a hard time finding where a given controller action is being called.

We use Ajax and I wonnder if that may be the reason it's hard for me to find.

I search for "MyActionName(" but it doees not show up.

Any suggestions?

Thanks.
0
newbieweb
Asked:
newbieweb
1 Solution
 
P1ST0LPETECommented:
Lets say we have a "HomeController", and inside this controller we have an "Index(int id)" method.

If I wanted to hit the Index method on the Home controller with AJAX, lets say using jQuery, I could have something like this:

$.ajax
({
        type: 'POST',
        url: '/Home/Index/' + id,
        success: function(data)
        {
               // do something with data
        }
});


or you could have just a link:

<a href="/Home/Index/123">Click Me</a>


or you could have mvc html helpers creating links for you such as:

@Html.Action("Index", "Home")
or
@Html.ActionLink("Click Me", "Index", "Home")


or you might have a View with a form on it like this:

@using (Html.BeginForm("Index", "Home", new { @id = 123 }))
{
      @* form elements here *@
}

and any <input type="submit"> elements on the above form that get clicked would hit that method


or you may check your global.asax file to see how the routing is working.  You may have a default route that is spilling into your method.
0
 
newbiewebAuthor Commented:
THANKS! Great Answer!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now