小编Mat*_*t.G的帖子

带有xml输入的.net Core 2.0 Web API httppost作为null出现

尝试获取.net core 2.0 Web API HttpPost方法以使用xml输入。

预期结果:从Postman调用测试端点时,输入参数(以下代码中的xmlMessage)应具有从Postman HttpPost主体发送的值。

实际结果:输入参数为空。

在Web api项目的startup.cs中,我们具有以下代码:

public class Startup
{
   public Startup(IConfiguration configuration)
   {
      Configuration = configuration;
   }

   public IConfiguration Configuration { get; }

   // This method gets called by the runtime. Use this method to add services to the container.
   public void ConfigureServices(IServiceCollection services)
   {
      services.AddMvc()
      .AddXmlDataContractSerializerFormatters();
   }

   // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
   public void Configure(IApplicationBuilder app, IHostingEnvironment env)
   { …
Run Code Online (Sandbox Code Playgroud)

.net c# asp.net-core-webapi asp.net-core-2.0

5
推荐指数
1
解决办法
3413
查看次数

标签 统计

.net ×1

asp.net-core-2.0 ×1

asp.net-core-webapi ×1

c# ×1