HttpPost方法解析错误的值(ASP.Net)

时间:2018-06-28 10:23:43

标签: asp.net-mvc debugging http-post

我的HttpPost方法或浏览器发送数据的方式出现问题。 当我输入一个值时,例如50.47(或50.47。分隔符似乎不是问题),POST中的值是50.47。到目前为止,一切似乎都还不错。但是控制器的Post Method解析错误的值并始终获得5047。

我使用以下输入:

<input asp-for="Preisnachlass" type="number" lang="de-de" step="0.01" min="0" class="form-control"/>

这是我的POST方法:

[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(int id, [Bind("BestellNr,BestellungsDatum,BestellStatus,BezahlungsDatum,VerwendungsDatum,Preisnachlass,GutscheinNr,KundenNr,ProduktNr")] Bestellung bestellung)
{
    if (id != bestellung.BestellNr)
    {
        return NotFound();
    }
    if (ModelState.IsValid)
    {
        try
        {
            _context.Update(bestellung);
            await _context.SaveChangesAsync();
        }
        catch (DbUpdateConcurrencyException)
        {
            if (!BestellungExists(bestellung.BestellNr))
            {
                return NotFound();
            }
            else
            {
                throw;
            }
        }
        return RedirectToAction(nameof(Index));
    }
    ViewData["GutscheinNr"] = new SelectList(_context.Gutschein, "GutscheinNr", "GutscheinNr", bestellung.GutscheinNr);
    ViewData["KundenNr"] = new SelectList(_context.Kunde, "KundenNr", "KundenNr", bestellung.KundenNr);
    ViewData["ProduktNr"] = new SelectList(_context.Produkt, "ProduktNr", "ProduktNr", bestellung.ProduktNr);`

    return View(bestellung);
}

当我调试整个过程时,这是我从chrome开发工具中得到的:

https://i.imgur.com/bNHSpKO.png(仅对发布链接有用)

vs就是Post方法:

https://i.imgur.com/Ba7GQ0U.png

我不知道如何更深入地调试它以发现问题。有人对此有想法吗?

0 个答案:

没有答案