Skip to content

Instantly share code, notes, and snippets.

@sakapon
Last active August 6, 2018 06:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sakapon/7e64aebcc538871e65c2f97c7ab88f69 to your computer and use it in GitHub Desktop.
Save sakapon/7e64aebcc538871e65c2f97c7ab88f69 to your computer and use it in GitHub Desktop.
AspNetCoreWebApiSample / Output Formatter
using System;
using Microsoft.AspNetCore.Mvc.Formatters;
using Microsoft.Extensions.DependencyInjection;
namespace SampleWebApi
{
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddCors();
// テキスト形式を無効化、XML 形式を有効化
services.AddMvc(options =>
{
options.OutputFormatters.RemoveType<StringOutputFormatter>();
options.OutputFormatters.Add(new XmlSerializerOutputFormatter());
});
// XML 形式を有効化
//services.AddMvc().AddXmlSerializerFormatters();
// 以下略
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment