I'm working on a web app in which a new user signs up in two steps.First the user provides basic credentials such as email and password.Then, the user is asked for some additional information such as Phone Number, Interest and so on. After filling the required information the user is redirected to a Home Page. What I am looking for is to prevent the user from directly navigating to the Home Page without finishing the signup process. Using this answer, I created an ActionFilter that prevents access to the Index action of the Home controller if the controller and action in the Referrer Uri are empty. Here is the code:
public class PreventNavAttribute : FilterAttribute, IActionFilter
{
private ILog logger = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public void OnActionExecuting(ActionExecutingContext filterContext)
{
string area = string.Empty, controller = string.Empty, action = string.Empty;
SetUpReferrerRouteVariables(filterContext.HttpContext.Request, ref area, ref controller, ref action);
logger.Info($"Controller: {controller} Action:{action}");
if (controller.IsEmpty() || action.IsEmpty())
{
filterContext.Result = new HttpNotFoundResult();
}
}
Using this method works, effectively preventing a user from directly navigating into the Index action. However, the caveat here is on the next visit the user cannot go directly to the Home page by typing the url to the website.
How can I solve this so that I can both prevent a new user from directly navigating to home page without finishing the signup and also allow the user to directly navigate to the home page on the next visit.