FileResult in controller and returning NotFound

Return NotFound() in FileResult. Just change return type to ActionResult, because FileResult inherits from ActionResult. And then it is possible to return NotFound() e.g. when object equals null.

So FileResult -> ActionResult, something like this:

public FileResult ActionResult GetFile(int id)
         var file = await service.Get();
         if(file == null) 
             return NotFound();
         return File(…);

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: