diff --git a/src/WebApiContrib.Core.Formatter.Csv/CsvOutputFormatter.cs b/src/WebApiContrib.Core.Formatter.Csv/CsvOutputFormatter.cs index 3b5077c..bc02b08 100644 --- a/src/WebApiContrib.Core.Formatter.Csv/CsvOutputFormatter.cs +++ b/src/WebApiContrib.Core.Formatter.Csv/CsvOutputFormatter.cs @@ -69,6 +69,10 @@ public async override Task WriteResponseBodyAsync(OutputFormatterWriteContext co var response = context.HttpContext.Response; Type type = context.Object.GetType(); + if (!type.IsGenericType || type.GetGenericTypeDefinition() != typeof(IEnumerable<>)) + { + type = type.GetInterfaces().First(z => z.GetGenericTypeDefinition() == typeof(IEnumerable<>)); + } Type itemType; if (type.GetGenericArguments().Length > 0)