使用ASP.NET以编程方式在IIS上创建新网站 [英] Creating a new website programmatically on IIS using ASP.NET

查看:81
本文介绍了使用ASP.NET以编程方式在IIS上创建新网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,这是我的要求。我正在建立一个多租户网站,公司在注册后可以获得自己的子域名。

假设我的公司名为Email Jobs Inc,域名为www.emailjobs.com。这个站点托管在一个共享的ISP环境中,所以我对IIS等的访问权限非常有限。



只是为了澄清一下,这是我需要的一个例子:



company1注册并获得此网址company1.emailjobs.com

company2注册并获得此网址company2.emailjobs.com

company3注册,他们得到这个网址:company3.emailjobs.com



我的理解是这里有一个DNS和IIS组件。也就是说,我需要更改DSN服务器中的条目,然后再更改IIS中的绑定。所有这些都非常棘手,因为非静态IP地址等等。



然而,我听说的另一个选择是要求你的ISP设置IIS通配符选项* .emailjobs.com直接进入我的ASP.NET MVC服务器。在那里,我可以解析URL,提取子域,我将在业务!对?



有人可以确认这是可能的吗?



我意识到我的另一个选择就是建立这样的网址:www.emailjobs.com/company1等,但这样会更不优雅。

我们将非常感谢任何反馈...



Best。

解决方案

是,您提出的解决方案是可能的,您可以在您描述的方案中使用子域而不是子目录(例如company.emailjobs.com而不是www.emailjobs.com/company)。



您可以使用通配符子域配置IIS,以便所有子域绑定到单个网站,然后在代码中使用正则表达式确定HTTP请求中子域的文本。你的正则表达式可能如下所示:



 ^(?< subdomain> \w +)\ ..emailjobs\.com 

< /子域>


So, here are my requirements. I am building a multi-tenant site where companies after they sign up get their own subdomain.
Assume that my business is called Email Jobs Inc with domain www.emailjobs.com. This site is hosted in a shared ISP environment so I have very limited access to IIS etc.

Just to clarify, here is an example of what I need:

company1 signs up and they get this url company1.emailjobs.com
company2 signs up and they get this url company2.emailjobs.com
company3 signs up and they get this url: company3.emailjobs.com

My understanding is that there is a DNS and IIS component to this. That is, I will need to change an entry in a DSN server and then also a binding in IIS. All this is very tricky, because of non-static IP addresses, etc. etc.

However, another option I heard of is to ask your ISP to setup an IIS wildcard option where *.emailjobs.com goes straight to my ASP.NET MVC server. There I can parse the URL, extract the subdomain and I would be in business! Right?

Could someone confirm that this is possible and correct?

I realize that another option I have is to build urls like this: www.emailjobs.com/company1 etc, but that would be far less elegant.
Any feedback would be greatly appreciated...

Best.

解决方案

Yes, the solution you have proposed is possible, and you can use sub-domains rather than sub-directories in the scenario you have described (e.g. company.emailjobs.com rather than www.emailjobs.com/company).

You can configure IIS with a wildcard sub-domain, so that all sub-domains bind to a single web site, and then use a regular expression in your code to determine the text for the sub-domain in an HTTP Request. Your regular expression might look something like this:

^(?<subdomain>\w+)\.emailjobs\.com


</subdomain>


这篇关于使用ASP.NET以编程方式在IIS上创建新网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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