如何仅使用 2 个虚拟目录托管多个 Web 应用程序
我的共享主机只允许我创建 2 个虚拟目录。 我想托管多个 Web 应用程序...比如 ASP.NET MVC 博客、论坛、个人网站等...
没有其他方法可以做到这一点吗? 我不能简单地将博客文件夹 ftp 到我的虚拟目录之一,然后在线访问它吗?
my shared hosting only allows me to create 2 virtual directories. and i want to host multiple webapps... say an asp.net mvc blog, a forum, a personal site etc...
isnt there any other way of doing this? cant i simply just ftp the blog folder to one of my virtual directories and then access it online??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于 ASP.NET Web 应用程序,通常每个应用程序都位于自己的虚拟目录中,该目录作为应用程序的起点。
从技术上讲,您可以通过以下两种方式之一“搭载”同一应用程序起点上的两个应用程序:
如果您没有任何重叠的文件,你可以摆脱这个。 当然,您可能不会使用默认页面或索引页面等文件。无论如何,这会很混乱。
仅当每个应用程序的二进制文件的名称不重叠并且程序集之间不存在命名空间歧义冲突(两个文件名不同的程序集,但具有相同的命名空间)时,您才能执行此操作。 如果您尝试搭载两个不同的应用程序,则后者发生的可能性要小得多。
我发现后一个解决方案的一个大问题是应用程序中使用应用程序根引用的任何部分都会损坏。 当某些代码尝试基于应用程序根引用(例如〜)解析对某些资源(例如图像)的引用时,
将解析为虚拟目录,但不会包含附加(非虚拟和非应用程序起点) ) 应用程序所在的子目录。 所以,
你最终会得到这样的结果:
显然,这是行不通的。
所以...如果您可以将它们放在同一个虚拟目录中,您就不会破坏任何一个应用程序,但是,您必须检查文件冲突等。 如果没有单独的应用程序起点,可能的命名空间冲突将是不可避免的。
For ASP.NET web applications, typically each would live in its own virtual directory which serves as the application starting point.
Technically you could "piggy-back" two applications on the same application starting point in one of two ways:
If you don't have ANY files that overlap, you can get away with this. Of course, it's likely that you won't with such files as the default or index pages, etc. And this would be pretty messy anyway.
You'll be able to do this only if each application's binary files don't overlap by name AND there are no namespace ambiguity conflicts between assemblies (two different assemblies by file name, but with the same namespace). The latter is much less likely to happen if you are trying to piggy-back two different applications.
The big problem I see with the latter solution is that any parts of the application that make use of application root references will break. When some code tries to resolve a reference to some resource (like an image) based on an application root reference such as
the ~ will get resolved to the virtual directory, but will not include the additional (non-virtual and non-app starting point) subdirectory in which the application lives. So instead of this:
you'll end up with this:
Obviously, that won't work.
So... you won't break either app if you can put them both in the same virtual directory, however, you'll have to check for file conflicts and such. Possible namespace conflicts will be unavoidable without separate application starting points.
您不能将每个应用程序放在任一虚拟目录中的单独子目录中吗? 例如,如果您有 http://server.com/vd1,您可以像 http://server.com/vd1/app1,http://server.com/vd1/app2 等
Can't you just put each app in a separate subdirectory in either of the virtual directories. e.g. if you had http://server.com/vd1, you could partition it like http://server.com/vd1/app1, http://server.com/vd1/app2, etc.