tags:

views:

27

answers:

1

I'm storing the xls file in sql server. And shown the details in Grid.

When multiple user try to access the file at a moment, If one user deletes the file and another user try to read the same file it throws error.

And now i'm checking whether the file is their or not, how can i show a message to user that file is deleted.

We suppose to return a ActionResult in Controller

A: 

You can return a different View from your controller if the file does not exist. Telling the user what has happned, so in your controller you would have

if (fileNotFound) return View("FileNotFound");
else return View(Model);

or you could pass a message into your view with ViewData telling the view if the file exists or not.

if (fileNotFound) ViewData["FileExists"] = "Nope";

And in your view check for this before you try to display the file in your grid.

<% if (ViewData["FileExists"] == "Nope") { %>
    <p>The file has been deleted or does not exists</p>
<% } else { %>
    Display your grid
<% } %>

I prefer the first option, it keeps your views cleaner.

theouteredge