MVCコアコントローラに単純なangularjsページからオブジェクトをポストする際に問題があります。MVCのコアアクションがangularjsからバインドされていませんPOST
MVCアクションでのオブジェクトは、オブジェクト自体がnullではないにもかかわらず、バインドされていません。これは通常の問題です。
私が間違っていることを誰も見ることができますか?
これは私の角度サービスコードです:
によって呼び出されthis.getQuote = function (priceRequest) {
return $http.post('/quote/getcost', { priceRequest });
};
:
this.quoteDataがあるquoteService.getQuote(this.quoteData).then(function (cost) {
$scope.quoteData.quoteCost = cost.data;
});
:
$scope.quoteData = {
detailLevel: '0',
fileLengthHours: 0,
fileLengthMinutes: 1,
excessiveSpeakersCount: 1,
industry: null,
deliveryTime: '1',
additionalInformation: '',
quoteCost: null
};
です
最後に私のC#MVCコアアクション:
に投稿されたオブジェクトがnullではありませんが、値のどれもがバインドされていない[HttpPost]
public JsonResult GetCost([FromBody]PriceRequest priceRequest)
{
var price = _priceCalculator.GetPrice(priceRequest);
return new JsonResult(price);
}
これはPriceRequestオブジェクトです:
public class PriceRequest
{
public JobDetailLevel DetailLevel { get; set; }
public int FileLengthHours { get; set; }
public int FileLengthMinutes { get; set; }
public int? ExcessiveSpeakersCount { get; set; }
public JobIndustry Industry { get; set; }
public JobDeliveryTime DeliveryTime { get; set; }
public string AdditionalInformation { get; set; }
}
誰かが私が間違っていることを見ることができますか?
.Net PriceRequestオブジェクトはどのように定義されていますか? – brad
Bradに質問に追加されました。文字列またはint以外のものは列挙型です – Simon
"POST"のスクリーンショットには本文がありません。身体はどのように見えますか? – Liam