Reputation: 11928
In asp.net mvc 2 web application I've created a controller and default actions work just fine(Index, Display, Create). Now I want to create a custom controller action which takes an object id and named, say, Rotate, I've created a public method which does some logic and redirects to the index page again.
The problem is that when I'm trying to call
<%: Html.ActionLink("Click on me", "Rotate", new { id = item.Id })%>
there's 404 error. What's the problem? Should I register that created controller action somewhere in order to use it?
EDIT:
public ActionResult Rotate(int id)
{
/* does some stuff to the object */
return RedirectToAction("Index");
}
URL is like this: http://localhost/Home/Rotate/1
Upvotes: 0
Views: 560
Reputation: 46018
If your controller and action match your default route (controller / action / id) than you don't need to do anything else to 'register' your action.
And you need to compile the project ;-)
Upvotes: 1