下面是送出資料的語法
public async Task AddRecord()
{
var JsValue = await JS.InvokeAsync<GetJsValue>("DateTimePicker");
workovertimeDto.WoStartTime = JsValue.woStartTime;
workovertimeDto.WoEndTime = JsValue.woEndTime;
workovertimeDto.WoSum = JsValue.woSum;
workovertimeDto.WoDate = DateTime.Parse(woDate);
workovertimeDto.CreateTime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
try
{
var response = await Http.PostAsJsonAsync<WorkovertimeRecordDto>("/api/workovertime", workovertimeDto);
var responseContent = await response.Content.ReadAsStringAsync();
var jsonSerializerOptions = new System.Text.Json.JsonSerializerOptions
{
PropertyNameCaseInsensitive = true
};
var workovertimeData = System.Text.Json.JsonSerializer.Deserialize<WorkovertimeRecordDto>(responseContent, jsonSerializerOptions);
}
catch (Exception e)
{
}
await JS.InvokeVoidAsync("CloseModal");
workovertime = await Http.GetFromJsonAsync<List<WorkovertimeRecordDto>>("/api/workovertime");
}
我下中斷點後還是不知道原因出在哪
只知道這段與法還沒執行完就會刷新頁面
然後欄位名稱和值就直接跑到網址列了
像是下面這張圖這樣