Create an interstitial page/option for users who haven't visited the site before

,

I have a requirement to create an option to have a visitor select from a list of options to continue to a specific part of the site if they’ve not been to the site before. How I’d see it working is if a cookie or stored value is empty for the visitor, then this option displays for the user to select from this list:

  1. Professional
  2. Residential
  3. Business
  4. Personal

When they select one of those options above, that value would be stored and they’d be directed to a given section on the site. Being newer to Umbraco, I’m not sure where I might capture this event, middleware, home page, somewhere else? Should it be a client action or a server action? My gut tells me I should make it a server action and register it in the middleware, however, maybe I’m overengineering it.

Does anyone have some experience they can share with me regarding this?

Hi Brendan,

Middleware would be a good fit for this and fairly simple as can just be added to the program.cs file, something like

app.Use(async (context, next) =>
{
    var hasVisited = context.Request.Cookies.ContainsKey("VisitedBefore");

    if (!hasVisited && !context.Request.Path.StartsWithSegments("/welcome"))
    {
        context.Response.Redirect("/welcome");
        return;
    }

    await next();
});

Then create your welcome page and controller to handle the selection