A sometime ago I asked this question and I was told that the entry has to be made in DNS etc. I was not sure whather all this is really required or not. The kind of feature that I am looking for is shown in the screenshot below:
一段时间以前我问了这个问题,我被告知必须在DNS等条目中输入。我不确定是否真的需要这些。我正在寻找的功能类型如下面的屏幕截图所示:
As you can see blogger lets the user choose the subdomain for his blog. How can we achieve this? I am basically developing in asp.net C#. How can I allow my users to choose subdomains like this once I have my top level domain. Currently I am developing on localhost.
正如您所看到的,blogger允许用户为其博客选择子域。我们怎样才能做到这一点?我基本上是在asp.net C#中开发的。一旦我拥有*域名,我怎样才能允许我的用户选择这样的子域名。目前我正在开发localhost。
Thanks in advance:)
提前致谢:)
2 个解决方案
#1
6
Use a wild card domain in IIS so it traps every request to the top level domain and under.
在IIS中使用通配符域,以便将每个请求捕获到*域及其下。
In asp.net: Create an HttpModule... this will run for every request and you can check the domain name, etc and pull in user information based on the sub-domain. An example httpmodule can be found at URL Rewriting in ASP.NET via HttpModule.
在asp.net中:创建一个HttpModule ...这将针对每个请求运行,您可以检查域名等,并根据子域提取用户信息。可以通过HttpModule在ASP.NET重写中找到示例httpmodule。
In asp.net mvc: Create a custom RouteHandler (custom based on interface IRouteHandler). Look at RouteHandler vs ControllerFactory question for an example.
在asp.net mvc中:创建一个自定义RouteHandler(基于接口IRouteHandler的自定义)。查看RouteHandler与ControllerFactory问题的示例。
#2
3
You need to add a wildcard DNS mapping that maps *.example.com
to your webserver, and a wildcard hostname mapping telling IIS to send all subdomains to your ASP.Net website.
您需要添加将* .example.com映射到您的Web服务器的通配符DNS映射,以及通配符主机名映射,告知IIS将所有子域发送到您的ASP.Net网站。
You can then check Request.Hostname
in server-side code and use the appropriate content (or error message)
然后,您可以在服务器端代码中检查Request.Hostname并使用适当的内容(或错误消息)
#1
6
Use a wild card domain in IIS so it traps every request to the top level domain and under.
在IIS中使用通配符域,以便将每个请求捕获到*域及其下。
In asp.net: Create an HttpModule... this will run for every request and you can check the domain name, etc and pull in user information based on the sub-domain. An example httpmodule can be found at URL Rewriting in ASP.NET via HttpModule.
在asp.net中:创建一个HttpModule ...这将针对每个请求运行,您可以检查域名等,并根据子域提取用户信息。可以通过HttpModule在ASP.NET重写中找到示例httpmodule。
In asp.net mvc: Create a custom RouteHandler (custom based on interface IRouteHandler). Look at RouteHandler vs ControllerFactory question for an example.
在asp.net mvc中:创建一个自定义RouteHandler(基于接口IRouteHandler的自定义)。查看RouteHandler与ControllerFactory问题的示例。
#2
3
You need to add a wildcard DNS mapping that maps *.example.com
to your webserver, and a wildcard hostname mapping telling IIS to send all subdomains to your ASP.Net website.
您需要添加将* .example.com映射到您的Web服务器的通配符DNS映射,以及通配符主机名映射,告知IIS将所有子域发送到您的ASP.Net网站。
You can then check Request.Hostname
in server-side code and use the appropriate content (or error message)
然后,您可以在服务器端代码中检查Request.Hostname并使用适当的内容(或错误消息)