I am using WebApi in a ASP.Net web application. I have a method in the controller called `Delete` and I want to access to this method by using jQuery's AJAX method.
Below is my code:

```
[Authorize]
public int Delete(int proposalId)
{
    // logic here...     
}

```

```js
$.ajax({
    url: "/Controller/Proposal/" + proposalId,
    type: "Post",
    contentType: "application/json",
    success: function() {
        bootbox.alert("Proposal deleted successfully.");
        ReloadGrid();
    },
    error: function() {
    }
});

```

```csharp
RouteTable.Routes.MapHttpRoute(
    name: "DefaultApi",
    routeTemplate: "controller/{controller}/{id}",
    defaults: new { id = RouteParameter.Optional }
);

```

```xml
<system.webServer>
    <modules runAllManagedModulesForAllRequests="true"></modules>
</system.webServer>

```

The problem is that when I am using `POST` it is executing another method which starts as Post. Can anyone please help me with this?
['https://Stackoverflow.com/questions/29123885', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1145184/']
Assuming this is accessing a REST API, you need to send a `DELETE` request by setting the appropriate `type` in your `$.ajax` call:

```
$.ajax({
    url: "/Controller/Proposal/" + proposalId,
    type: "DELETE", // <- Change here
    contentType: "application/json",
    success: function() {
        bootbox.alert("Proposal deleted successfully.");
        ReloadGrid();
    },
    error: function() {
    }
});

```
If you must use a custom method for deletion for example, you can always rely on setting HTTP attributes -- like so:

```
[HttpDelete]
[Route("api/Proposal")]
public IHttpActionResult Proposal(long id){
   ...
}

```