I have a link on the page that allows the user to perform a certain action if they are logged in. If they are not logged in I want the link to direct them to the login page first. This pretty common. What's the best way to do this? Currently I'm doing this but I don't like it:
<% if(Model.IsUserAuthenticated){ %>
<%= Html.ActionLink("Start Puzzle", "StartPuzzle", "Puzzles")%>
<%} else { %>
<%= Html.ActionLink("Start Puzzle", "Login", "Account")%>
<%} %>
You get the idea. I don't really like having logic in the view like this. Is it better to just have the "StartPuzzle" action redirect if not logged in?
Thanks