2017-01-10 11 views
0

私は単純なモデルを持っているasp.netコアにModelState badrequest一貫性のない行動

サンプル#1:

POST http://localhost:5000/api/v1/items 
content-type: application/json 

{ 
    "name": "sample1", 
    "cost": $100000 
} 

応答:

{ 
    "cost": [ 
    "The input was not valid." 
    ] 
} 

サンプル#2:

POST http://localhost:5000/api/v1/items 
content-type: application/json 

{ 
    "name": "sample2", 
    "cost": "10000000000000000000000000" 
} 

応答:

{ 
    "cost": [ 
    "The input was not valid." 
    ] 
} 

サンプル#3:この1つはバグのように思えます。空のキーは、(代わりに範囲エラーのうちint型の)表示されます

POST http://localhost:5000/api/v1/items 
content-type: application/json 

{ 
    "name": "sample3", 
    "cost": 10000000000000000000000000 
} 

応答:

{ 
    "": [ 
    "The input was not valid." 
    ], 
    "cost": [ 
    "The input was not valid." 
    ] 
} 

編集: 追加githubの上の追跡チケット - https://github.com/aspnet/Mvc/issues/5672

答えて

0

初と最後の無効なjsonであり、2番目の値は整数costの数値が大きすぎます。あなたの費用はINT_MAX: 2147483647を超えないようにしてください。

+0

私はそれを知っていますが、なぜエラーはキーのない追加のプロパティを示しています –

+0

あなたの質問は、ごめんなさい。私の推測では、最後に開いた '' 'を見つけ出し、新しい値を開始すると考えています。名前が定義されていないので、空で無効なものとして出力します。新たな価値であり、むしろ 'の前に'コスト 'の一部です。私はgithub https://github.com/aspnet/Homeで報告します – Mats391

関連する問題