I have a controller named BearController. In it I have one index action method and another action method.
public ActionResult EditBear(int bearId)
{
...
return View();
}
Here is how I call it from the view of the index method:
$.ajax({ url: "Bear/EditBear", data: { bearId: 2} })
The method gets called, the breakpoint goes through the end of EditBear, and after that in my browser I get the view from the index method. The url in the browser is the url of the index method (which means only localhost and controllerName).
I also tried with:
$.get('@Url.Action("EditBear", "Bear")', { bearId: 2});
and the method doesn’t even gets called. What is the problem?
As it seems, if you call an action method with Ajax, the view is somehow not shown. I had to use window.location.href to get the correct view.