出于某种目的将多个域/子域指向同一个网站或在一个代码库上运行多个网站是否可行?
仅用一个代码库运行一堆网站是否可能或可行?
例如,我有 1 个站点,其连接字符串基于域名或子域名。因此,根据访问该网站的域/子域,该网站将返回专门针对该网站存储在数据库中的内容。
这样做可能会出现什么类型的问题?特别是如果使用 asp.net 执行此操作。
Is it possible or feasible to run a bunch off web sites off of only 1 code base?
For example I have 1 site that bases it's connection string off of the domain name or subdomain name. So, depending on what domain/subdomain is hitting the site the site returns content that is stored in a database specifically for that site.
What types of issues might occur from doing this? Specifically if doing this with asp.net.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是相当可以接受的。
请注意,任何人都可以更改您可能选择的域名(只要您为其配置了主机标头),因此请确保您不会四处制作类似“admin.foo”的内容,而仅依赖于出于安全考虑(显然你会生气)。
我认为没有问题。
It's quite acceptable.
Just note that anyone can change the domain name that you may pick up (as long as you've configured a host header for it), so just make sure you don't go around making something like 'admin.foo' but relying only on that for security (you'd be mad though, obviously).
I see no problem with it.
它有效并且已经被证明。 Se DotNetNuke 只是其中的 1 个示例。
请求进来。正则表达式/字符与域名匹配。加载该域的设置(图像、CSS、配置、页面等的基本路径),然后就可以了。
It works and is proven. Se DotNetNuke for just 1 example of this.
Request come in. Regex/character matchthe domain name. Load settings for that domain (base path to images, css, config, pages etc etc) and off you go.
需要注意的问题是您的应用程序是否 a) 在内存中存储数据 b) 使用相同的应用程序空间。因此,例如,如果您想要发布两个不同的博客,并且希望数据驻留在内存中(例如,如果您的后端存储是 XML,并且您不想对每个请求都解析 XML),那么您必须确保 Asp.Net 将每个调用视为一个单独的应用程序(它们都可以指向相同的文件系统文件夹,从而使用相同的文件)。
我在编写BlogEngine.Net 的多博客数据提供程序时遇到了这种情况。它使用单一代码库根据请求的 URL 提供不同的博客。但是,由于 BlogEngine.Net 将其数据存储在内存中,因此数据提供程序将无法工作,除非将 IIS 配置为每个博客都是其自己的应用程序。
The gotcha to look out for is if your application is both a) storing data in memory and b) using the same application space. So if, for example, you want to dish up two different blogs and you want the data to be resident in memory (if, say, your back-end store was XML and you didn't want to parse XML with every request) then you'll have to make sure that Asp.Net sees each call as a separate application (which can both point to the same file-system folder and thus uses the same files).
I ran into this exact situation when coding a multi-blog data provider for BlogEngine.Net. It uses a single code base to serve up different blogs based on the requested URL. However, since BlogEngine.Net carries its data in memory, the data provider won't work unless IIS is configured so that each blog is its own application.