我可以在一个会员数据库下运行多个网站吗?

发布于 2024-09-04 21:45:46 字数 272 浏览 4 评论 0原文

我正在尝试规划一系列共享许多资源的网站,例如 css/jscript/images/content 等。因此,我想在同一应用程序和 IIS 配置文件下运行所有​​网站,但具体取决于所使用的 URL 会更改母版页和主题/皮肤。

ASP.NET 成员数据库似乎是为了这个目标而设计的,因为它允许您设置多个应用程序,但我相信构建它的目的是允许应用程序在虚拟目录/文件夹下运行,而不是在虚拟目录/文件夹下运行。在单独的 URL 上。

是否可以将 url 映射到特定应用程序?

提前致谢 铝

I'm trying to plan a series of websites that all share many of the resources such as css/jscript/images/content etc. For this reason I wanted to run all of the websites under the same application and IIS profile, but depending on the URL being used change the masterpage and theme/skin.

The ASP.NET membership database seems as if it was designed with this goal in mind because it allows you to setup multiple applications, however I believe the purpose for which this was built was to allow applications to be run under virtual directories/folders, not on separate URLs.

Is it possible to map a url to a particular application?

Thanks in advance
Al

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

捶死心动 2024-09-11 21:45:46

是的,可以这样做。在您的配置中,使用您的提供程序的 applicationName。这样,所有数据都将保存在同一个数据库中,但通过您在大多数表中可以找到的应用程序 ID 分开。

共享资源的一种可能性是将它们仅放在一个位置,然后您可以通过使用第一个位置中文件的完整 URL 从其他站点指向该位置。

另一种可能性是将一个应用程序托管在同一域的虚拟目录中,尽管这样做可能会遇到 web.config 继承的一些有趣问题。如果您显示这两个应用程序的预期域名,将会有所帮助。

在一个应用程序中:
web.config 1:

<roleManager enabled="true">
    <providers>
        <clear/>
        <add name="AspNetSqlRoleProvider" applicationName="/ApplicationOne"
            ...add other properties here as standard
     />
    </providers>
</roleManager>
<membership>
    <providers>
        <clear/>
        <add name="AspNetSqlMembershipProvider" applicationName="/ApplicationOne"
            ...add other properties here as standard
         />
    </providers>
</membership>

在您的其他应用程序中:
网络配置2:

<roleManager enabled="true">
    <providers>
        <clear/>
        <add name="AspNetSqlRoleProvider" applicationName="/ApplicationTwo"
            ...add other properties here as standard
     />
    </providers>
</roleManager>
<membership>
    <providers>
        <clear/>
        <add name="AspNetSqlMembershipProvider" applicationName="/ApplicationTwo"
            ... add other properties here as standard
         />
    </providers>
</membership>

Yes it is possible to do this. In your configuration, use the applicationName for your providers. This way, all of the data will be saved in the same database, but kept separate by the Application Id that you will find in most of the tables.

One possibility for your shared resources can be to put them in just one location and you can point to that location from your other site by using a full url to the file in the first location.

Another possibility is to host one app in a virtual directory in the same domain, although you can get into some interesting issues with web.config inheritance doing this. It would help if you show your intended domain naming for the two applications.

In one application:
web.config 1:

<roleManager enabled="true">
    <providers>
        <clear/>
        <add name="AspNetSqlRoleProvider" applicationName="/ApplicationOne"
            ...add other properties here as standard
     />
    </providers>
</roleManager>
<membership>
    <providers>
        <clear/>
        <add name="AspNetSqlMembershipProvider" applicationName="/ApplicationOne"
            ...add other properties here as standard
         />
    </providers>
</membership>

In your other application:
web.config 2:

<roleManager enabled="true">
    <providers>
        <clear/>
        <add name="AspNetSqlRoleProvider" applicationName="/ApplicationTwo"
            ...add other properties here as standard
     />
    </providers>
</roleManager>
<membership>
    <providers>
        <clear/>
        <add name="AspNetSqlMembershipProvider" applicationName="/ApplicationTwo"
            ... add other properties here as standard
         />
    </providers>
</membership>
温折酒 2024-09-11 21:45:46

最简单的解决方案是根据页面正在执行的 URL 来包含样式表,使用:

Request.ServerVariables("SERVER_NAME")

IE(伪):

if Request.ServerVariables("SERVER_NAME") = "http://www.domain1.com" then
  include stylesheet1
else
  include stylesheet2
end if

您需要找到一个函数来从 URL 中提取域名,这样它才能正常工作。

The easiest solution would be to include the style sheet depending on what URL the page is being executed on, using:

Request.ServerVariables("SERVER_NAME")

IE (pseudo):

if Request.ServerVariables("SERVER_NAME") = "http://www.domain1.com" then
  include stylesheet1
else
  include stylesheet2
end if

You would need to find a function to extract the domain name from the URL so it works well.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文