This repository was archived by the owner on Dec 14, 2018. It is now read-only.

Description
Is this a Bug or Feature request?:
Bug, regression
Steps to reproduce or link to a repro project:
- Create an Asp.Net Core api project
- Update package to use 2.1.0-rc1-final
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Folder Include="wwwroot\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.1.0-rc1-final" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.4" />
</ItemGroup>
</Project>
- Add XmlSerializerOutputFormatter in MVC option
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc(options =>
{
options.OutputFormatters.Add(new XmlSerializerOutputFormatter());
});
}
- Update a ValuesController method to use async
public async Task<IEnumerable<string>> Get()
{
return await Task.FromResult(new string[] { "value1", "value2" });
}
- run the project
- send a request using Accept: application/xml
GET /api/values HTTP/1.1
Host: localhost:61519
Accept: application/xml
Description of the problem:
An InvalidCastException is thrown
InvalidCastException: Unable to cast object of type 'System.String[]' to type 'System.Threading.Tasks.Task1[System.Collections.Generic.IEnumerable1[System.String]]'.
Version of Microsoft.AspNetCore.Mvc or Microsoft.AspNetCore.App or Microsoft.AspNetCore.All:
Microsoft.AspNetCore.All Version="2.1.0-rc1-final"