asp.net-core.net-6.0multi-tenantsaas

Managing static files in SAAS application in ASP.NET Core 6


I’m developing a SaaS app its like shopify. I want each “tenant” of the SaaS app to have their own theme, but a theme isn’t just a different style sheet or colors, a theme could be totally different layouts (so different views).

How would I go about this?

1- Is it good approach to store tenant theme and its related static files like css, js and images into application into wwwroot or in other place with in application? If not how i can manage it?

I am using following frameworks 1- ASP.NET Core 6 2- Finbuckle (Tenant resolver)

Thanks


Solution

  • I’m developing a SaaS app its like shopify. I want each “tenant” of the SaaS app to have their own theme, but a theme isn’t just a different style sheet or colors, a theme could be totally different layouts (so different views). How would I go about this?

    Actually, now a days dynamic theming is more expected in regards of multi tenant application. Considering your scenario you should have different layout files to manage tenant specific static files.

    Most common approach to theming in ASP.NET Core MVC is to create a layout page for each theme that references specific css and js files.

    For instance, you could have tenant specific theme or you can have theme which can be used within all theme.

    Furthermore, regarding the implementation, you would need a class where you would define your tenant configuration. Based on your configuration you would read those value from your appsetting.json file.

    Is it good approach to store tenant theme and its related static files like css, js and images into application into wwwroot or in other place with in application? If not how i can manage it?

    Depending on requirement and scenario both approach would be correct. The key difference is while you would read static file from wwwroot directory you don't require to use additional file directory reference within your program.cs file.

    Regarding the implementation, you should have a middleware which would mapp your static files accross the tenant. You can get more details here.

    Note: While you would start implementation meanwhile, if you encounter any issue , please share your concern with reproducible code snippet. Up to now, I think above explanation and linked document would assist you to know the approach. In addition, you can refer the guideline here.