Sitefinity Discover FormResponse MetaFields for custom export
Ever needed to programmatically access Sitefinity form response data? Maybe you're building an integration, or you're on a version before 15 where the built-in export crashes when you have too many rows.
The tricky part is MVC forms dynamically generate their entry types, so you can't just reflect on a known class. The field names are buried in Sitefinity's metadata system.
The Solution: MetadataManager
Use MetadataManager combined with TypeResolutionService to discover the actual form fields at runtime:
var formEntryType = TypeResolutionService.ResolveType(form.EntriesTypeName);
var metadataManager = MetadataManager.GetManager();
var metaType = metadataManager.GetMetaType(formEntryType);
foreach (var field in metaType.Fields)
{
if (!field.IsInternal)
// This is an actual form field
}
This gives you all the custom fields defined on the form without hardcoding anything.
Full Handler Implementation
I built an HTTP handler that takes a form name and date range, discovers all the fields, and exports everything to a proper Excel file using OpenXML.
Usage
Just drop it in and call it:
/FormDownload.ashx?Name=ContactForm&FromDate=2026-01-01
It's restricted to backend users only, so random visitors can't download your form data.
The MetadataManager approach also has a reflection fallback in case the metadata lookup fails, so it works across different Sitefinity versions.