Hi guys, I have an ASP.NET MVC application. In the application, I have a bunch of similarly structured routes for different actions:
/Admin/Addresses/{AddressId}/Delete
/Admin/Phones/{PhoneId}/Delete
/Admin/Notes/{NoteId}/Delete
/Admin/Files/{FileId}/Delete
None of which work... I have been checking the routes and the actions for 5 hours now, and I know they are all written the way they should be, but it's still 404ing all of them.
The funny thing is that the following routes, which are also similar in structure work just fine:
/Admin/Addresses/{Id}/{Type}
/Admin/Phones/{Id}/{Type}
/Admin/Notes/{Id}/{Type}
/Admin/Files/{Id}/{Type}
The only difference between the two sets is that the delete routes use GET and are supposed to return JSON, while the othere ones use POST and redirect.
Has anyone ran into this before?
EDIT: Here's a bigger code sample per the requests on the comments. First code sample is of the ONLY working route (which is probably because it's the first in the list of routes to use the specified url structure) and the second is the next route in line, which isn't working at all...
Routes.MapRoute("Administration (Delete Employee)", "Administration/Employees/{EmployeeId}/Delete", new {
controller = "Administration",
action = "DeleteEmployee"
});
[AcceptVerbs(HttpVerbs.Get)]
public JsonResult DeleteEmployee(short EmployeeId) {
try {
db.DeleteEmployee(EmployeeId);
return Json(new IJsonStatus() {
Success = true
});
} catch (Exception ex) {
Shared.LogWarning(ex);
return Json(new IJsonStatus() {
Success = false,
Exception = ex.Message
});
};
}
And the non-working route:
Routes.MapRoute("Administration (Delete Address)", "Administration/Addresses/{AddressId}/Delete", new {
controller = "Administration",
action = "DeleteAddress"
});
[AcceptVerbs(HttpVerbs.Get)]
public JsonResult DeleteAddress(int AddressId) {
try {
db.DeleteAddress(AddressId);
return Json(new BaseResponse() {
Success = true
});
} catch (Exception ex) {
Shared.LogWarning(ex);
return Json(new BaseResponse() {
Success = false,
Exception = ex.Message
});
};
}