由于逗号正在删除,我无法用json中的逗号将数字反序列化为十进制,例如123,99被12399替换.
我发现了类似的问题: 在Newtonsoft.Json中处理十进制值 但是我更容易,因为它是一个标准数字,其中dot是逗号,我不需要使用特定文化进行解析.我怎样才能做到这一点?
public class PriceModel
{
public decimal Price { get; set; }
}
string json = @"{'Price': '1234,99'}";
PriceModel priceModel = JsonConvert.DeserializeObject<PriceModel>(json);
Run Code Online (Sandbox Code Playgroud) 我无法在ASP.NET Core中使用@ Url.Action,因为出现错误:
IUrlHelper没有名为Action的适用方法
我想将@ Url.Action用于:
<a href="@(Url.Action(ViewBag.actionName, ViewBag.controllerName, new { page = i }) + ViewBag.routeValues)">page i</a>
Run Code Online (Sandbox Code Playgroud)
在ASP.NET MVC中,它生成了我的网址,例如:
/ Home / List?page = 5&search = abc
在ViewBag.routeValues中,我传递其他参数,例如:search = abc&active = true并将其粘贴到'page'参数之后的 url中。
我认为使用标签帮助程序和“ asp-route”无法做同样的事情-那我该怎么办?
好的-我需要将ViewBag字符串化:
<a href="@(Url.Action((string)ViewBag.actionName, (string)ViewBag.controllerName, new { page = i }) + (string)ViewBag.routeValues)">page i</a>
Run Code Online (Sandbox Code Playgroud)