We need to support different internal stores for our re-sellers using their Id as the subdomain. I am trying to migrate an existing system to NopCommerce where the system behaves this way.

For example,

3001.mystore.com (site for reseller 3001)
3002.mystore.com (site for reseller 3002)
3003.mystore.com (site for reseller 3003)
...

I have customized application_beginRequest to extract the subdomain and validate the reseller Id (3001, 3002, 3003 in the example above). Buyers registers through the reseller website and resellers get their commission. You can think of resellers lot like affiliates in NopCommerce except that the resellers have their own subdomain. The real kicker is that we can't share all registered users across multiple resellers.

Browser points to 3001.mystore.com
Customer "3001C" logs in to the site. We validate and make sure that "3001C" is indeed registered with 3001.mystore.com
Browser points to 3002.mystore.com
As customer "3001C" is not registered under 3002.mystore.com, we need to logout the existing user and show a clean home page

I have created an action filter on the HomeController to check the subdomain and force the user to logout like this.

..
var authenticationService = EngineContext.Current.Resolve<IAuthenticationService>();
authenticationService?.SignOut();
..

This doesn't seem to help. I tried to redirect to "HomePage" after signing out using AuthenticationService and this created a redirect loop on Chrome.


Any other ideas? Sorry - long winded question. I am trying different options for the past couple of days without any success.