- ABP Framework version: Latest
- UI Type: Angular
- Database System: MySQL
- Tiered (for MVC) or Auth Server Separated (for Angular): Auth server Separete
- Exception message and full stack trace:
- Steps to reproduce the issue:
I am trying to test Multi-Tenancy in the new module i just created. I am able to get the token and I can see the __tenantId being passed in the header. I put a logger in the module to check the TenantId and its always coming null
public class SampleController : VendorManagementController, ISampleAppService
{
private readonly ISampleAppService _sampleAppService;
private readonly ILogger<SampleController> _logger;
public SampleController(ISampleAppService sampleAppService, ILogger<SampleController> logger)
{
_sampleAppService = sampleAppService;
_logger = logger;
}
[HttpGet]
public async Task<SampleDto> GetAsync()
{
if (CurrentTenant.Id.HasValue)
_logger.LogInformation("TenantId :" + CurrentTenant.Id);
else
_logger.LogInformation("TenantId is null");
return await _sampleAppService.GetAsync();
}
[HttpGet]
[Route("authorized1")]
[Authorize]
public async Task<SampleDto> GetAuthorizedAsync()
{
return await _sampleAppService.GetAsync();
}
}
I also tried to use Swagger and no success Can you help me understand how I can get the TenantId properly, is there any settings I need to switch on or something
7 Answer(s)
-
0
Did you add the
MultiTenancy
middleware?app.UseMultiTenancy();
-
0
Where do I add this ? Should I add this in the Module or Micro Service ? Please provide a little more clearer instructions. I am coming from AspNetZero background but this is pretty new to me, so little bit more explanation is helpful. And when I added the the microservices I rememeber adding Multitenancy as true as that was the default selection
-
0
i don't know your project details,
could you share a minimal reproducible project with me. i will check it.
shiwei.liang@volosoft.com
-
0
I have sent the link to download the module and micro service
-
0
-
0
I need some calrifications around the app.useMultiTenancy(). I tried with doing it as th Microservice level only and it didn't work and then I had to add it to the module level and then it started working. So the question is do we need to add MultiTenancy at the Module and microservice level.
If not can you please explain whats the right way to go about it
-
0
Hi,
you have to add it to the module level. since modules can be designed to be multi-tenant or not