Reputation: 26048
I have an Index view. On this view is a link, and it is created like this:
<%= Html.ActionLink("Clear All", "ClearAll", "CachedCollections") %>
I don't want to have a view for ClearAll, I just want it to go in the method, clear what it needs to clear and then post back to the Index view. How would I do this? Do I need to call a method for this?
EDIT:
Here is my code:
[HttpPost]
public ActionResult ClearAll()
{
Debug.Print("Got to here");
return RedirectToAction("Index", CachedDictionaryCollectionManager.List);
}
From my action link it's not hitting this action method. It just tells me that the resource is not found when I click on it.
Please advise.
Thanks.
Upvotes: 2
Views: 136
Reputation: 71288
in the called action you return RedirectToAction("Index");
public ActionResult ClearAll()
{
...
return RedirectToAction("Index","Home");
//Home is the controller name, don't specify it if you redirect to an action from the same controller
}
Upvotes: 1
Reputation: 4209
Action methods don't really need to return anything:
Use: Return new EmptyResult();
Upvotes: 1