-1

I have method, that return FileContentResult:

    public FileContentResult fileStream(string EAN)
    {
        //Finding byte[] of PDF
        byte[] pdf = findPDF(EAN);

        return new FileContentResult(pdf, "application/pdf");
    }

And I use it in iframe:

<iframe src="@Url.Action("fileStream", "Approve", new { EAN = Model.ID_EAN })" frameborder="0"></iframe>

What should I return if pdf is null (FileContentResult is null). Now it shows Error page with controller name and controller action.

Michal Fiala
  • 75
  • 2
  • 9

1 Answers1

6

I've changed return value of my method to ActionResult and returned new HttpNotFoundResult();

    public ActionResult fileStream(string EAN)
    {
        //Hledani byte[] pdf
        byte[] pdf = findPDF(EAN);

        if (pdf == null)
            return new HttpNotFoundResult();

        return new FileContentResult(pdf, "application/pdf");
    }
Michal Fiala
  • 75
  • 2
  • 9