Forum Discussion

POOP's avatar
POOP
New Member
24 days ago

Can't upload files within a nested object Asp.NET

I'm working with asp.net.

Usually when you want to include file data in your http request you can use the interface IFormFile within your input object. For example, if I define the object

public class A {

public IFormFile file {get; set; }

}

 

and then an endpoint:

public ActionResult Test([FromForm] A a) {...}

it will generate a GUI that lets you upload a file.

This is all fine but I'm encountering a case where it has problems.

If a define an object B that contains a collection of A:

 

public class A {

public IEnumerable<A> objects {get; set; }

}

 

then the generated GUI won't let me upload a file for the nested field B.A.File and instead it treats it as a simple string.

 

If anyone has a solution for this it'd help me very much

 

 

No RepliesBe the first to reply