I have a problem I'm struggling with. Some background: Users can in my application choose which color scheme for the app to use, this choice is stored in a database.
What I want to do is based on this choice, on page load, serve the CSS file for the choice the user made.
What I've been trying to do is check the users choice by doing an AJAX request in the _Layout.cshtml page, appending the appropriate CSS to the header. This is working but not great, since there is some delay and it just not a good solution since at times some styling for elements are not correct after the CSS has been loaded.
What I would like to do is to do this check server-side, like for a normal view in the controller (Layout pages lacks controllers as you know so this is where I'm stuck). And then in the _Layout view add the correct CSS.
So dear stack overflowers, do you have any suggestions for me how this could be achieved? My users need that sweet sweet dark theme. ;)
Thanks in advance!
_Layout. This might be the right moment to use this functionality. You can also make use of html tag helpers or components to get a cleaner syntax instead of using these dirtyifi'm suggesting ... (netcore 2 is awesome, go use it right now !)