它會接受所有的HTTP方法。
看略有格式片段從ActionMethodSelector.cs(ASP.NET MVC源可以下載here):
private static List<MethodInfo> RunSelectionFilters(ControllerContext
controllerContext, List<MethodInfo> methodInfos)
{
// remove all methods which are opting out of this request
// to opt out, at least one attribute defined on the method must
// return false
List<MethodInfo> matchesWithSelectionAttributes = new List<MethodInfo>();
List<MethodInfo> matchesWithoutSelectionAttributes = new List<MethodInfo>();
foreach (MethodInfo methodInfo in methodInfos)
{
ActionMethodSelectorAttribute[] attrs =
(ActionMethodSelectorAttribute[])methodInfo.
GetCustomAttributes(typeof(ActionMethodSelectorAttribute),
true /* inherit */);
if (attrs.Length == 0)
{
matchesWithoutSelectionAttributes.Add(methodInfo);
}
else
if (attrs.All(attr => attr.IsValidForRequest(controllerContext,
methodInfo)))
{
matchesWithSelectionAttributes.Add(methodInfo);
}
}
// if a matching action method had a selection attribute,
// consider it more specific than a matching action method
// without a selection attribute
return (matchesWithSelectionAttributes.Count > 0) ?
matchesWithSelectionAttributes :
matchesWithoutSelectionAttributes;
}
所以,如果沒有更好的匹配有明確的屬性,操作方法操作方法,無需屬性將使用。
我的猜測是任何(包括PUT,DELETE)。我想你可以通過實驗找出 - 在沒有AcceptVerbs屬性的情況下做一個簡單的測試操作,對它發出一些不同的請求,看看會發生什麼。我很想知道答案:-) – 2009-07-02 10:53:42