如何在asp.net中创建子域?

时间:2022-06-25 21:12:11

How can I create a subdomain in an asp.net C# application? I am working with an asp.net portal. In that portal I need to be able to create the subdomain at runtime. The ftp for that subdomain also needs to be the same as the main domain ftp.

如何在asp.net C#应用程序中创建子域?我正在使用asp.net门户。在该门户中,我需要能够在运行时创建子域。该子域的ftp也需要与主域ftp相同。

5 个解决方案

#1


5  

There are a handful of working parts here. It sounds like the requirement is that this all happen at runtime. I am sure a lot of web hosting providers are deep into these sets of problems and likely have custom solutions.

这里有一些工作部件。听起来要求就是这一切都发生在运行时。我相信很多网络托管服务提供商都深入研究这些问题并且可能有自定义解决方案。

DNS: you'll need to have an API open at the DNS host. If it's a LAN environment, you'll have to check your DNS provider on whether they have APIs exposed. (i.e. Windows Server or whatever your network operating system is). If this is a public facing site that needs to be accessed via the internet, you'll have to get those APIs from the DNS registrar. Are the subdomains to be permanent?

DNS:您需要在DNS主机上打开API。如果是LAN环境,则必须检查DNS提供商是否已公开API。 (即Windows Server或您的网络操作系统)。如果这是一个需要通过互联网访问的面向公众的网站,您必须从DNS注册商处获取这些API。子域是永久性的吗?

IIS: You'll have to setup wildcard mapping, (i.e. *.mydomain.net). When an HTTP request comes in, logic within the ASP.NET page can determine the subdomain that you're working with. You could extract the subdomain, perform a lookup on that subdomain to get more information (CustomerID, names, valid visitor IP address ranges, whathaveyou).

IIS:您必须设置通配符映射(即* .mydomain.net)。当HTTP请求进入时,ASP.NET页面中的逻辑可以确定您正在使用的子域。您可以提取子域,在该子域上执行查找以获取更多信息(CustomerID,名称,有效的访问者IP地址范围,whathaveyou)。

FTP: if you require secure logins for that subdomain, you'd have to have created AD or local machine accounts for those users. If you want anonymous access, that's OK too. There are some scripting options that you'll have to look at to have that FTP folder setup as well. That is assuming you're using IIS's FTP module. If you are using a 3rd party FTP application, that complicates the scenario even further. Their APIs would have to be investigated.

FTP:如果您需要为该子域进行安全登录,则必须为这些用户创建AD或本地计算机帐户。如果你想要匿名访问,那也没问题。您还需要查看一些脚本选项,以便设置FTP文件夹。假设您正在使用IIS的FTP模块。如果您使用的是第三方FTP应用程序,则会进一步使情况复杂化。他们的API必须进行调查。

Active Directory: If you are requiring secure access for each subdomain, you'll have to create AD users and/or groups. You can certainly script the creation of users into groups. Perhaps the users will be local to your web server. That doesn't scale well if you want to add another web server, but it's certainly do-able.

Active Directory:如果要求对每个子域进行安全访问,则必须创建AD用户和/或组。您当然可以将用户的创建编写成组。也许用户将是您的Web服务器的本地用户。如果你想添加另一个Web服务器,这不能很好地扩展,但它肯定可行。

#2


0  

subdomain's are controlled by your dns settings. Beyond that I can't understand your question.

子域名由您的DNS设置控制。除此之外,我无法理解你的问题。

#3


0  

I think the best way is to have a wildcard DNS entry - i.e. *.domain.com that points to the domain. And then use a rewriting tool, like helicontech.com, to rewrite the 1st part of the subdomain to tell your app what you're looking at.

我认为最好的方法是使用通配符DNS条目 - 即* .domain.com指向域。然后使用重写工具(如helicontech.com)重写子域的第一部分,告诉您的应用程序您正在查看的内容。

This would use regular expressions to pass the subdomain to your app:

这将使用正则表达式将子域传递给您的应用:

RewriteCond Host: (mysub).domain.com RewriteRule (.*) /$2?subdomain=$1 [I,L,U]

RewriteCond主持人:(mysub).domain.com RewriteRule(。*)/ $ 2?subdomain = $ 1 [I,L,U]

#4


0  

There are two halves to this: A) Changing your DNS Settings: This varies based on your host and whatnot. Contact them and ask if you can't figure it out.

这有两个部分:A)更改DNS设置:这取决于您的主机和诸如此类的东西。联系他们,询问您是否无法弄明白。

B) Changing your host settings: This varies based on your server. I assume you're using some version of IIS.

B)更改主机设置:这取决于您的服务器。我假设您正在使用某些版本的IIS。

In IIS6, you can right click a web site, select the properties page, go to the web site tab, select advanced in web site identification, and start adding bindings (Generally you'll use default or the ip address for IP Address, 80 for TCP Port (unless SSL), and the site for the host header file (e.g. www.example.com or subdomain.example.com).

在IIS6中,您可以右键单击一个网站,选择属性页面,转到网站选项卡,选择网站标识中的高级,然后开始添加绑定(通常,您将使用默认或IP地址的IP地址,80用于TCP端口(除非是SSL),以及主机头文件的站点(例如www.example.com或subdomain.example.com)。

In IIS7, you right click on a website and select edit bindings, then click "Add". IIS7's add screen is pretty self explanatory.

在IIS7中,右键单击网站并选择编辑绑定,然后单击“添加”。 IIS7的添加屏幕非常自我解释。

#5


0  

I think he wants to created a subdomain from code, using an API probably that needs to be provided by his webhost folks. Like his own DNS manager app. If I interpreted your question wrong, then I guess you probably oughta reiterate a bit more.

我想他想用代码创建一个子域,使用一个可能需要由他的webhost人员提供的API。就像他自己的DNS管理器应用程序如果我把你的问题解释错了,那么我猜你可能要重申一点。

#1


5  

There are a handful of working parts here. It sounds like the requirement is that this all happen at runtime. I am sure a lot of web hosting providers are deep into these sets of problems and likely have custom solutions.

这里有一些工作部件。听起来要求就是这一切都发生在运行时。我相信很多网络托管服务提供商都深入研究这些问题并且可能有自定义解决方案。

DNS: you'll need to have an API open at the DNS host. If it's a LAN environment, you'll have to check your DNS provider on whether they have APIs exposed. (i.e. Windows Server or whatever your network operating system is). If this is a public facing site that needs to be accessed via the internet, you'll have to get those APIs from the DNS registrar. Are the subdomains to be permanent?

DNS:您需要在DNS主机上打开API。如果是LAN环境,则必须检查DNS提供商是否已公开API。 (即Windows Server或您的网络操作系统)。如果这是一个需要通过互联网访问的面向公众的网站,您必须从DNS注册商处获取这些API。子域是永久性的吗?

IIS: You'll have to setup wildcard mapping, (i.e. *.mydomain.net). When an HTTP request comes in, logic within the ASP.NET page can determine the subdomain that you're working with. You could extract the subdomain, perform a lookup on that subdomain to get more information (CustomerID, names, valid visitor IP address ranges, whathaveyou).

IIS:您必须设置通配符映射(即* .mydomain.net)。当HTTP请求进入时,ASP.NET页面中的逻辑可以确定您正在使用的子域。您可以提取子域,在该子域上执行查找以获取更多信息(CustomerID,名称,有效的访问者IP地址范围,whathaveyou)。

FTP: if you require secure logins for that subdomain, you'd have to have created AD or local machine accounts for those users. If you want anonymous access, that's OK too. There are some scripting options that you'll have to look at to have that FTP folder setup as well. That is assuming you're using IIS's FTP module. If you are using a 3rd party FTP application, that complicates the scenario even further. Their APIs would have to be investigated.

FTP:如果您需要为该子域进行安全登录,则必须为这些用户创建AD或本地计算机帐户。如果你想要匿名访问,那也没问题。您还需要查看一些脚本选项,以便设置FTP文件夹。假设您正在使用IIS的FTP模块。如果您使用的是第三方FTP应用程序,则会进一步使情况复杂化。他们的API必须进行调查。

Active Directory: If you are requiring secure access for each subdomain, you'll have to create AD users and/or groups. You can certainly script the creation of users into groups. Perhaps the users will be local to your web server. That doesn't scale well if you want to add another web server, but it's certainly do-able.

Active Directory:如果要求对每个子域进行安全访问,则必须创建AD用户和/或组。您当然可以将用户的创建编写成组。也许用户将是您的Web服务器的本地用户。如果你想添加另一个Web服务器,这不能很好地扩展,但它肯定可行。

#2


0  

subdomain's are controlled by your dns settings. Beyond that I can't understand your question.

子域名由您的DNS设置控制。除此之外,我无法理解你的问题。

#3


0  

I think the best way is to have a wildcard DNS entry - i.e. *.domain.com that points to the domain. And then use a rewriting tool, like helicontech.com, to rewrite the 1st part of the subdomain to tell your app what you're looking at.

我认为最好的方法是使用通配符DNS条目 - 即* .domain.com指向域。然后使用重写工具(如helicontech.com)重写子域的第一部分,告诉您的应用程序您正在查看的内容。

This would use regular expressions to pass the subdomain to your app:

这将使用正则表达式将子域传递给您的应用:

RewriteCond Host: (mysub).domain.com RewriteRule (.*) /$2?subdomain=$1 [I,L,U]

RewriteCond主持人:(mysub).domain.com RewriteRule(。*)/ $ 2?subdomain = $ 1 [I,L,U]

#4


0  

There are two halves to this: A) Changing your DNS Settings: This varies based on your host and whatnot. Contact them and ask if you can't figure it out.

这有两个部分:A)更改DNS设置:这取决于您的主机和诸如此类的东西。联系他们,询问您是否无法弄明白。

B) Changing your host settings: This varies based on your server. I assume you're using some version of IIS.

B)更改主机设置:这取决于您的服务器。我假设您正在使用某些版本的IIS。

In IIS6, you can right click a web site, select the properties page, go to the web site tab, select advanced in web site identification, and start adding bindings (Generally you'll use default or the ip address for IP Address, 80 for TCP Port (unless SSL), and the site for the host header file (e.g. www.example.com or subdomain.example.com).

在IIS6中,您可以右键单击一个网站,选择属性页面,转到网站选项卡,选择网站标识中的高级,然后开始添加绑定(通常,您将使用默认或IP地址的IP地址,80用于TCP端口(除非是SSL),以及主机头文件的站点(例如www.example.com或subdomain.example.com)。

In IIS7, you right click on a website and select edit bindings, then click "Add". IIS7's add screen is pretty self explanatory.

在IIS7中,右键单击网站并选择编辑绑定,然后单击“添加”。 IIS7的添加屏幕非常自我解释。

#5


0  

I think he wants to created a subdomain from code, using an API probably that needs to be provided by his webhost folks. Like his own DNS manager app. If I interpreted your question wrong, then I guess you probably oughta reiterate a bit more.

我想他想用代码创建一个子域,使用一个可能需要由他的webhost人员提供的API。就像他自己的DNS管理器应用程序如果我把你的问题解释错了,那么我猜你可能要重申一点。