{"action":"created","issue":{"url":"https://api.github.com/repos/aspnet/Mvc/issues/3692","labels_url":"https://api.github.com/repos/aspnet/Mvc/issues/3692/labels{/name}","comments_url":"https://api.github.com/repos/aspnet/Mvc/issues/3692/comments","events_url":"https://api.github.com/repos/aspnet/Mvc/issues/3692/events","html_url":"https://github.com/aspnet/Mvc/issues/3692","id":120479363,"number":3692,"title":"ASP.NET MCV returns Content-Type text/plain even if application/xml was requested in case of return type is string","user":{"login":"YEVHENO","id":12974070,"avatar_url":"https://avatars.githubusercontent.com/u/12974070?v=3","gravatar_id":"","url":"https://api.github.com/users/YEVHENO","html_url":"https://github.com/YEVHENO","followers_url":"https://api.github.com/users/YEVHENO/followers","following_url":"https://api.github.com/users/YEVHENO/following{/other_user}","gists_url":"https://api.github.com/users/YEVHENO/gists{/gist_id}","starred_url":"https://api.github.com/users/YEVHENO/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/YEVHENO/subscriptions","organizations_url":"https://api.github.com/users/YEVHENO/orgs","repos_url":"https://api.github.com/users/YEVHENO/repos","events_url":"https://api.github.com/users/YEVHENO/events{/privacy}","received_events_url":"https://api.github.com/users/YEVHENO/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-12-04T20:25:19Z","updated_at":"2015-12-07T16:24:54Z","closed_at":null,"body":"This is my controller:\r\n\r\n[Route(\"\")]\r\npublic class ValuesController : Controller\r\n{\r\n    //This always returns text/plain\r\n    [HttpPost(\"/text\")]\r\n    [Produces(\"application/xml\", \"application/json\")]\r\n    public string GetText() => \"Some text\";\r\n\r\n    [HttpPost(\"/textarray\")]\r\n    [Produces(\"application/xml\", \"application/json\")]\r\n    public IEnumerable<string> GetTextarray() => new[] { \"Some text\", \"Some text2\" };\r\n}\r\n\r\nGetText() always returns text/plain even if I specify \"Accept: application/xml\" in request header. This happens only in case of return type \"string\".  I expect get xml instead of plain text. See sample requests below:\r\n\r\nRequest 1:\r\nGET /text HTTP/1.1\r\nHost: localhost:5004\r\nAccept: application/xml\r\n\r\nResponse 1:\r\nHTTP/1.1 200 OK\r\nDate: Fri, 04 Dec 2015 20:13:00 GMT\r\nContent-Type: text/plain; charset=utf-8\r\nServer: Kestrel\r\n\r\nSome text\r\n\r\nRequest 2:\r\nGET /textarray HTTP/1.1\r\nHost: localhost:5004\r\nAccept: application/xml\r\n\r\nResponse 2:\r\nHTTP/1.1 200 OK\r\nDate: Fri, 04 Dec 2015 20:13:04 GMT\r\nContent-Type: application/json; charset=utf-8\r\nServer: Kestrel\r\n\r\n<ArrayOfString xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><string>Some text</string><string>Some text2</string></ArrayOfString>\r\n"},"comment":{"url":"https://api.github.com/repos/aspnet/Mvc/issues/comments/162576673","html_url":"https://github.com/aspnet/Mvc/issues/3692#issuecomment-162576673","issue_url":"https://api.github.com/repos/aspnet/Mvc/issues/3692","id":162576673,"user":{"login":"rynowak","id":1430011,"avatar_url":"https://avatars.githubusercontent.com/u/1430011?v=3","gravatar_id":"","url":"https://api.github.com/users/rynowak","html_url":"https://github.com/rynowak","followers_url":"https://api.github.com/users/rynowak/followers","following_url":"https://api.github.com/users/rynowak/following{/other_user}","gists_url":"https://api.github.com/users/rynowak/gists{/gist_id}","starred_url":"https://api.github.com/users/rynowak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rynowak/subscriptions","organizations_url":"https://api.github.com/users/rynowak/orgs","repos_url":"https://api.github.com/users/rynowak/repos","events_url":"https://api.github.com/users/rynowak/events{/privacy}","received_events_url":"https://api.github.com/users/rynowak/received_events","type":"User","site_admin":false},"created_at":"2015-12-07T16:24:54Z","updated_at":"2015-12-07T16:24:54Z","body":"I'd try adding the following to your startup code:\r\nmvc.AddMvcOptions(options =>\r\n{\r\n    options.OutputFormatters.RemoveType<StringOutputFormatter>();\r\n});\r\n\r\nWe have a formatter registered by default that treats strings as `text/plain` content.\r\n\r\nYou could also bypass formatters if your content is already in the format you want.\r\n\r\n```\r\nreturn Content(text, \"application/xml\");\r\n```"}}