如何做到在Asp.Net的mvc大本营式的帐户? [英] How to do Basecamp-style accounts in Asp.Net Mvc?

查看:103
本文介绍了如何做到在Asp.Net的mvc大本营式的帐户?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关一个Asp.Net软件即服务应用程序,我想这样做基于账户的Basecamp一样子域和37Signals公司产品具有的其余部分。例如。 acme.myapp.com将加载账户客户和背部只能拉动他们的信息。

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 the account for that customer and pull back only their information.

这是很容易在Ruby中做on Rails的,但你会如何处理ASP.NET MVC此功能,并能扩展到可能几百个账户?

This is easy to do in Ruby on Rails, but how would you handle this functionality in ASP.NET MVC and be able to scale to possibly hundreds of accounts?

推荐答案

我们使用:

public static string GetSubDomain()
        {
            string subDomain = String.Empty;

            if (HttpContext.Current.Request.Url.HostNameType == UriHostNameType.Dns)
            {
                subDomain = Regex.Replace(HttpContext.Current.Request.Url.Host, "((.*)(\\..*){2})|(.*)", "$2");
            }

            if (subDomain.Length == 0)
            {
                subDomain = "www";
            }

            return subDomain.Trim().ToLower();
        }

这篇关于如何做到在Asp.Net的mvc大本营式的帐户?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆