HttpRequest Form 如何正確讀資料
讀取HttpRequest的Form時沒資料就會產生System.InvalidOperationException: 'Incorrect Content-Type: '
要先用判斷HasFormContentType是true 才能去存取HttpRequest的Form
範例code
private static Dictionary<string,StringValues> ReadFormByRequest(HttpRequest request)
{
if (request.HasFormContentType)
{
var formDictionary = request.Form.ToDictionary(x => x.Key, x => x.Value);
}
}
如果內容有誤請多鞭策謝謝