views:

57

answers:

4

i have a controlled called AppController.

i have 2 actions: Details and Delete

both pass in int id as the parameter to the action

WHen i go to:

mysite/App/Details/100

I can catch it in the controller details action but when i go to

mysite/App/Delete/100

The breakpoint never hits and i get this in the browser:

Server Error in '/' Application.
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.

any idea what might be happening?

A: 

Possibly you need to compile, or there is an attribute on the Delete method requiring a POST rather than GET.

RedFilter
A: 

Check to make sure that the verb attribute that you are allowing is the same as the type of request that you are making. For what it's worth, you should be making a delete using POST or DELETE, so if it's not responding to a GET that's a good thing. Doing a delete action with a GET request (which can be easily bookmarked) is asking for trouble. Note that to use the DELETE verb, you're likely going to have to send the request via AJAX as most browsers won't make one on their own.

Less likely, but still possible -- the method needs to be public and can't be decorated with the NonActionAttribute.

tvanfosson
A: 

It may be down to the browsers cache, try emptying your cache and try again. I get this problem quite a bit when I use chrome.

Rippo
A: 

When you make a call to the Delete() method in your AppController using

mysite/App/Delete/100

you are requesting access via the Http Get verb.

Asp.Net MVC allows access to your public controller methods available by the Get verb by default

so you do not have to decorate your method with the following filter

[AcceptVerbs(HttpVerbs.Get)]

you can try this out by adding your to your Details method the following filter

[AcceptVerbs(HttpVerbs.Post)]

and then it will start receiving the Http 404 message as access will be restricted to a Http Post request.

Nicholas Murray