MVC Requesting File Download - how to handle no file available?
<p>I'm relatively new to MVC but suppose I have a <code>@Html.ActionLink(....</code> on my page that links to an Action that generates a file and returns it using:</p>

<pre><code>return File(memoryStream, "application/vnd.ms-excel");
</code></pre>

<p>This all works well until there's some kind of issue - either something's gone wrong or there's no file to return.</p>

<p>Returning <code>null</code> makes the webpage go to a blank page. So my question is... How can I gracefully handle this scenario? - ideally displaying some error to the user that something went wrong or there's no file/data available or if this isn't possible, then just ensuring the page doesn't go to a blank page, and just remains as it is.</p>

<p>I suppose I could redirect to the index action but this will refresh the page - are there any alternatives.</p>