There is no difference in these two code snippets, they have the same purpose, so the method only accepts requests from verb
% with%, in fact one is abbreviation of the other. In the source HttpGetAttribute is very clear that it is the abbreviation for AcceptVerbsAttribute :
Code < HttpGetAttribute :
using System.Reflection;
namespace System.Web.Mvc
{
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
public sealed class HttpGetAttribute : ActionMethodSelectorAttribute
{
private static readonly AcceptVerbsAttribute _innerAttribute =
new AcceptVerbsAttribute(HttpVerbs.Get);
public override bool IsValidForRequest(ControllerContext controllerContext,
MethodInfo methodInfo)
{
return _innerAttribute
.IsValidForRequest(controllerContext, methodInfo);
}
}
}
Source and copyright Copyright (c) Microsoft Open Technologies, Inc. All rights reserved at link
One advantage of using GET
is that it can contain more than one type of AcceptVerbs()
, example :
[AcceptVerbs(HttpVerbs.Get | HttpVerbs.Post)]
or
[AcceptVerbs("GET", "POST")]
so the method accepts requests from verb
verb
or GET
in the example
Note that if there is no configuration (
POST
,
[HttpGet]
or
[HttpPost]
, etc.) the method accepts by
Remarks: standard [AcceptVerbs("POST")]
verb
References: