ある内の項目数は、あなたがFormOptions
を使用して、デフォルトのformvalueの制限を変更することができたときに、この要求は完全に正常に動作します。 MVCを使用している場合は、フィルターを作成し、この制限を拡張し、残りのアクションのデフォルトを保持するアクションにデコレートできます。
/// <summary>
/// Filter to set size limits for request form data
/// </summary>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
public class RequestFormSizeLimitAttribute : Attribute, IAuthorizationFilter, IOrderedFilter
{
private readonly FormOptions _formOptions;
public RequestFormSizeLimitAttribute(int valueCountLimit)
{
_formOptions = new FormOptions()
{
ValueCountLimit = valueCountLimit
};
}
public int Order { get; set; }
public void OnAuthorization(AuthorizationFilterContext context)
{
var features = context.HttpContext.Features;
var formFeature = features.Get<IFormFeature>();
if (formFeature == null || formFeature.Form == null)
{
// Request form has not been read yet, so set the limits
features.Set<IFormFeature>(new FormFeature(context.HttpContext.Request, _formOptions));
}
}
}
アクション:
[HttpPost]
[RequestFormSizeLimit(valueCountLimit: 2000)]
public IActionResult ActionSpecificLimits(YourModel model)
注:あなたの行動があまりにもAntiforgery検証をサポートする必要がある場合、あなたはフィルタを注文する必要があります。例:
// Set the request form size limits *before* the antiforgery token validation filter is executed so that the
// limits are honored when the antiforgery validation filter tries to read the form. These form size limits
// only apply to this action.
[HttpPost]
[RequestFormSizeLimit(valueCountLimit: 2000, Order = 1)]
[ValidateAntiForgeryToken(Order = 2)]
public IActionResult ActionSpecificLimits(YourModel model)
「大量のjsonフォームデータ」とはどういう意味ですか?データを 'application/x-www-form-urlencoded'コンテンツタイプまたは' application/json'として投稿していますか? –
@KiranChalla私はContent-Typeを使用しています:application/x-www-form-urlencoded –