It's an option to push the tenant id in the URL or have a hidden field. It just seemed like it was an inelegant solution that meant I would have to touch more of the existing codebase. Then have to test more. Didn't really want to spend more than a few hours on this problem.
I don't think I mentioned it but the admin system was originally just to look after one tenant - two tenants meant two different admin systems. So this new admin system was really bringing that together, along with a few other features. So I really was working with an existing codebase and database.
Guids would have made the whole thing safer but there you go.
- Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
- Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!
Collapse
You are not logged in or you do not have permission to access this page. This could be due to one of several reasons:
- You are not logged in. If you are already registered, fill in the form below to log in, or follow the "Sign Up" link to register a new account.
- You may not have sufficient privileges to access this page. Are you trying to edit someone else's post, access administrative features or some other privileged system?
- If you are trying to post, the administrator may have disabled your account, or it may be awaiting activation.
Logging in...
Previously on "Multi-tenant ASP.NET core application, handling multiple tabs?"
Collapse
-
Originally posted by woohoo View PostFor what it's worth in case anyone is still interested. I ended up implementing SignalR.
Each connection (tab/window) is added to a group based on username, when the tenant is selected from the drop down, javascript calls a method via ajax to set the cookie tenant value (could have done it via javascript). Then a server side method on the tenant hub is called from the client. This method broadcasts to the group and triggers a method on the browsers belonging to that group and redirects to the home page.
A bit overkill if im honest, but found it interesting.
Leave a comment:
-
For what it's worth in case anyone is still interested. I ended up implementing SignalR.
Each connection (tab/window) is added to a group based on username, when the tenant is selected from the drop down, javascript calls a method via ajax to set the cookie tenant value (could have done it via javascript). Then a server side method on the tenant hub is called from the client. This method broadcasts to the group and triggers a method on the browsers belonging to that group and redirects to the home page.
A bit overkill if im honest, but found it interesting.
Leave a comment:
-
Originally posted by woohoo View PostIm not really a fan of the way MS handle switching between tenants. It's a mess tbh.
If you look at Xero for example they do it almost exactly how I want.
My feeling is I will have to dive into ASP.NET core lifecycle and check earlier in the page lifecycle and redirect if the value in the cookie changes.
Leave a comment:
-
Im not really a fan of the way MS handle switching between tenants. It's a mess tbh.
If you look at Xero for example they do it almost exactly how I want.
My feeling is I will have to dive into ASP.NET core lifecycle and check earlier in the page lifecycle and redirect if the value in the cookie changes.
Leave a comment:
-
There is a reason why MS will throw you got of the first tenant if you enter a second one.
I don't think there is a solution beyond adding enough state information / logic within the Web page to know what tenant the page belongs to and when the tenant no longer matches throw an error message.
MS's solution when asked about this is to train users to use the multiple profiles that are now available on chrome and Edge, my advice would be the same.
Leave a comment:
-
Multi-tenant ASP.NET core application, handling multiple tabs?
I have an admin system, the customer can select a tenant from a drop down box and website redirects to the tenant home page. The customer can continue to maintain the tenant data.
The problem I could have is if a customer opens tenant A in tab 1, then in tab 2 opens tenant B. If they go back to tab 1 and save a customer record for example it will try to save the record against tenant b.
I use a scoped tenant class with a connection string in it, middleware on each request checks a cookie for the tenant id and places the tenant connection string in the scoped class. The scoped class is used by the repositories to retrieve the correct tenant data.
So in the example above tab 2 will change the cookie tenant id, the middleware will change the scoped connection string and when tab 1 saves its using tenant B connection string.
I have a nasty JavaScript hack that keeps track of open admin tabs and closes and warns the user. It's a nasty hack, causing more issues that it's worth.
Anyone any ideas, oh and I really want to avoid having the tenant id in the query string. I'm thinking of something earlier in the life cycle of the page to catch the change and in this case redirect the request to the home page for the tenant.
I know it's a long shot, but any ideas? Stackoverflow has failed me. Thanks in advance.Tags: None
- Home
- News & Features
- First Timers
- IR35 / S660 / BN66
- Employee Benefit Trusts
- Agency Workers Regulations
- MSC Legislation
- Limited Companies
- Dividends
- Umbrella Company
- VAT / Flat Rate VAT
- Job News & Guides
- Money News & Guides
- Guide to Contracts
- Successful Contracting
- Contracting Overseas
- Contractor Calculators
- MVL
- Contractor Expenses
Advertisers
Contractor Services
CUK News
- Streamline Your Retirement with iSIPP: A Solution for Contractor Pensions Sep 1 09:13
- Making the most of pension lump sums: overview for contractors Sep 1 08:36
- Umbrella company tribunal cases are opening up; are your wages subject to unlawful deductions, too? Aug 31 08:38
- Contractors, relabelling 'labour' as 'services' to appear 'fully contracted out' won't dupe IR35 inspectors Aug 31 08:30
- How often does HMRC check tax returns? Aug 30 08:27
- Work-life balance as an IT contractor: 5 top tips from a tech recruiter Aug 30 08:20
- Autumn Statement 2023 tipped to prioritise mental health, in a boost for UK workplaces Aug 29 08:33
- Final reminder for contractors to respond to the umbrella consultation (closing today) Aug 29 08:09
- Top 5 most in demand cyber security contract roles Aug 25 08:38
- Changes to the right to request flexible working are incoming, but how will contractors be affected? Aug 24 08:25
Leave a comment: