I have a link on a page that allows the user to perform a specific action if they are logged in. If they are not logged in, I want the link to them to go to the login page first. This is pretty common. What is the best way to do this? I am currently doing this, but I do not like this:
<% 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 that view. Is it better to simply redirect the "StartPuzzle" action if you are not logged in?
Micah source
share