Last active
August 6, 2018 06:38
-
-
Save sakapon/7e64aebcc538871e65c2f97c7ab88f69 to your computer and use it in GitHub Desktop.
AspNetCoreWebApiSample / Output Formatter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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