views:

210

answers:

1

I have a file DownloadResult.cs extended from ActionResult(actually cloned from Phil Haack's one, which u can find at the following location Phil's blog )

Here how do i handle an exception(file not found ) thrown from the method ExecuteResult() in the controller level .

for the source code you might want to look at Phil's code , which is available at the link provided above.

looking forward for ur thoughts .

thanks, vijay

A: 

You should implement a global error catching mechanism.

I recommend the approach explained in this question How can I properly handle 404s in ASP.NET MVC?

If you want a nicer message in your action result, you simply can add a try catch block and if the file does not exists:

 Throw New HttpException(404, "The file you want to download does not exists.")
Eduardo Molteni