多租户在asp.net web表单

编程入门 行业动态 更新时间:2024-10-17 09:43:39
本文介绍了多租户在asp 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 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表单

本文发布于:2023-11-14 04:11:46,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1586180.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:租户   表单   net   asp   web

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!