Q:

making HTTP post request with confirmation message for delete

I want to delete an item by getting confirmation from user & I want to delete it with POST method.
Here's my code snippet
  @Html.ActionLink("Delete","Delete",new { id=item.UserId },new AjaxOptions {HttpMethod = "POST", Confirm = "Do you really want to delete this?"})

& my action method is:
    [HttpPost]
    public ActionResult Delete(int? id, LearningMVC.Models.User userDetails)
    {
        try
        {
            var dbContext = new MyDBDataContext();
            var user = dbContext.Users.FirstOrDefault(userId => userId.UserId == id);
            if (user != null)
            {
                dbContext.Users.DeleteOnSubmit(user);
                dbContext.SubmitChanges();
            }

            return RedirectToAction("Index");
        }
        catch
        {
            return View();
        }
    } 

If I remove the [HttpPost] attribute, It just deletes the record without any confirmation. It's giving 404 error with [HttpPost] attribute.
I have included jquery-1.5.1.min.js, unobtrusive-ajax.js, MicrosoftAjax.js, MicrosoftMvcAjax.js in the said order in layout page.
what I am missing here?

A:

I believe that you wanted to write:
@Ajax.ActionLink("Delete", "Delete",
    new { id = item.UserId },
    new AjaxOptions { HttpMethod = "POST", Confirm = "Do you really want to delete this?" })

Just use AjaxHelper instead of HtmlHelper.

