2

我将值从 C# 应用程序传递到已创建的 ASP.NET MVC Web API。我了解到,当我的值包含“\”时,如下所示:

{ id:"1", path:"D:\Backup\DataSource\MyFile.txt", name:"test" }

MyAction 中的参数为空。

[HttpPost]
public CustomResponse MyAction(CustomEntity entity)
{
  ... // do stuff
}

public class CustomEntity
{
  public string id { get; set; }
  public string path { get; set; }
  public string name { get; set; }
}

如果路径不包含“\”,则一切都按预期工作。我猜这是某种类型的编码问题。但是,在将值从 C# 应用程序发送到 Web API 之前,我不确定需要使用哪种编码。

我需要使用哪种编码?

4

0 回答 0