简体   繁体   English

如何根据租户动态更改资源路径(我们正在根据主机名确定租户)?

[英]How to change resource path dynamically based on the tenant(we are determining tenant based on host name)?

I'm trying to set up multi-tenancy with different set of resource files for each tenant separated in different folders. 我正在尝试为在不同文件夹中分隔的每个租户设置具有不同资源文件集的多租户。 Where should I set the resource path to pick the folder based on tenant(By the way I'm identifying tenant based on hostname)? 我应该在哪里设置资源路径以根据租户选择文件夹(通过基于主机名的方式来识别租户)?

Here is the folder structure I'm having - 这是我的文件夹结构-

资料夹结构

As of Now I hardcoded the value to Tenant1 in ConfigureServices section of startup.cs as shown below 从现在开始,我在startup.cs的ConfigureServices部分将值硬编码为Tenant1,如下所示

services.AddLocalization(options => options.ResourcesPath = "Resources/Tenant1");

Where can I reset this path based on the Host name and how to do it? 我在哪里可以根据主机名重置此路径,以及如何做?

You need to implement your own IStringLocalizerFactory which should creates IStringLocalizer based on the current tenant. 您需要实现自己的IStringLocalizerFactory ,该IStringLocalizerFactory应基于当前租户创建IStringLocalizer Take a look at this to get an idea on how to write your custom factory ResourceManagerStringLocalizerFactory.cs 对此进行了解,以了解如何编写自定义工厂ResourceManagerStringLocalizerFactory.cs

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 多租户 - 为每个租户动态创建数据库 - Multi tenant - create database dynamically for each tenant 如何在ASP.Net中使用Okta设计基于多租户应用程序的基于声明的身份系统 - How to design claims based identity system for multi tenant application with Okta in ASP .Net 根据用户参数动态确定依赖性 - Dynamically determining dependency based on user parameters 如何在多租户主机的自己的应用程序域中托管可能的恶意代码? - How do I host possibly malicious code in its own app domain in a multi-tenant host? 根据请求值确定动作方法的名称 - Determining the name of the action method based on request values 动态确定应用程序是基于Winform还是基于ASP.NET - Dynamically determining if application is Winform based or ASP.NET based 通过上下文覆盖将基于 EF 的应用程序转换为多租户 - Convert EF-based app to multi-tenant by way of context overrides 实体框架核心多租户:基于另一个列值的自动增量列 - Entity framework core multi tenant : auto increment column based in another column value 在多租户应用程序中基于路由参数自动设置Controller属性 - Automatically set Controller properties based on route parameters in multi-tenant application 基于多租户Asp.net核心网站中的参数的JWT身份验证 - JWT authentication based on the Parameter in Multi-tenant Asp.net Core web site
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM