How to do Basecamp-style accounts in Asp.Net Mvc?

前端 未结 3 1489
傲寒
傲寒 2021-02-06 13:30

For an Asp.Net software as a service application, I want to do account based subdomains like Basecamp and the rest of the 37Signals products have. E.g. acme.myapp.com will load

3条回答
  •  深忆病人
    2021-02-06 14:00

    It's not very different compared to RoR. Just get the HTTP-Request, take the Host-Value, split it (at each dot) and take the first part to get the subdomain.

    string subdomain = requestContext.HttpContext.
                          Request.Headers["Host"].Split('.')[0];
    

    Then just resolve the subdomain to the Companies account.

提交回复
热议问题