Say I have an asp.net mvc website with a page that lists products. ON that page I have a "delete" button that should only show up for the user that inserted the product. What's the best way to do this?
One way I thought of doing it was setting a boolean in the controller to let the view know if the button should be displayed. Something like:
if(IsProductOwner(UserId))
ViewData["CanDelete"] = true;
Then in the view I can just do
<% if((boolean)ViewData["CanDelete"] == true) { %>
// show delete button
<% } %>
But is there a better way to do this?