I would like to use a different layout view for anonymous users. I have tried using url alternates and I am not sure how I can create a layout for anonymous users since there is no particular url for them.
The idea is that, if a new user visits the site I want to show a splash screen with very limited information with an option to register/ login to view the full site. This splash screen will have a completely different layout / look and feel from the rest of the site.
I tried using the Anonymous user layer but all I could do was move widgets (maybe I am missing something).
Any help would be greatly appreciated.
Thanks!
There is no out of the box solution but you can do something like this to get what you want:
Add new layout in a file with the name of your choosing – for example, you could name it
Splash.cshtml.Add the code below to the top of your
Layout.cshtmltemplate:The code will check if the user is logged in. If it’s not, it will render the content of your
Splash.cshtmltemplate, and stop the rendering of the rest of theLayout.cshtmltemplate.If you need to display any of the widgets in your
Splash.cshtmltemplate, you could add it by simply adding@Display(Layout.NameOfTheZone)where you should replaceNameOfTheZonewith the actual name of the zone you’re using inside theLayout.cshtmltemplate. Generally, anything that you use insideLayout.cshtmltemplate with theModelobject, you can use throughLayoutobject inside any of your views.