多租户在asp.net web表单 [英] Multitenancy in asp.net web forms

查看:99
本文介绍了多租户在asp.net web表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创造了在Visual Studio 2010中新的Web窗体应用程序只有两个页面 Default.aspx的 About.aspx 。我想要的是,当我在调试Visual Studio开发服务器应用程序,并输入 HTTP://company1.localhost:1023 它应该与消息只是显示默认页面这是公司1默认页面。我怎么能只用URL路由玩,而不是在IIS结果做设置做
注意:我的理解是多租户是一个大词,不应该用这样一个简单的场景,但我的要求很简单。我只想运行应用程序,每家公司没有扩展点的同一个实例。这个问题也可以说,我如何通过编程创建子域。

i have created a new web forms application in visual studio 2010 with just two pages Default.aspxand About.aspx. what i want is that when i debug the app in visual studio development server it and enter http://company1.localhost:1023 it should just display Default page with message This is default page for company1. How can i do it with just playing with url routing as opposed to doing settings in IIS
Note: I understand that multi-tenancy is a big word and should not be used for such a simple scenario but my requirements are simple. i would just run same instance of the application for each company with no extension points. This question could also be stated as how can i create subdomains programmatically.

推荐答案

您必须对这项工作正确配置IIS(也许DNS)。例如,所有的子域应当由指定的网站在IIS处理。通常情况下,你可以配置IIS来处理所有的主机头如果只有单一的网站,但在多个Web站点的情况下,IIS通常配置为主机头不同。所以得到这个配置权限是你的重要组成部分。

You have to configure IIS (and perhaps DNS) correctly for this work. For example, all your sub-domains should handle by the designated web-site in IIS. Typically, you may configure IIS to handle all host-headers if there are only single web site but in case of multiple web-sites, IIS is typically configured to differ by host header. So getting this configuration right is the important part for you.

一旦你到达正确的网站,资源处理将被IIS元基地完成。所以在这种情况下,将重新直接为现场配置的默认资源。如果资源名称为present然后扩展(HTM,ASPX)将决定处理。 ASPX扩展将通过ASP.NET处理,那么所有你需要做的是寻找电流主机头,并作出相应的决定。例如,

Once you reach to the correct web-site, resource handling will be done by IIS meta-base. So in this case, it would re-direct to configured default resource for the site. If resource-name is present then extension (htm, aspx) will decide the handling. Aspx extensions will handled by ASP.NET and then all you need to do is to look up current host header and take a decision accordingly. For example,

protected void Page_Load(object sender, EventArgs e)
{
    if (request.Url.HostNameType == UriHostNameType.Dns)
    {
       var hostParts = Request.Url.Host.Split('.');
       // you may validate if sub-domain name is present or not
       lblMessage.Text = "This is default page for " + hostParts[0];
    }  
}

这篇关于多租户在asp.net web表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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