IIS7应用程序配置

发布于 2024-10-08 05:13:11 字数 313 浏览 1 评论 0原文

我有一个自定义 ASP.NET 应用程序,用于我托管的多个客户端。每个客户端都有一个单独的域,应用程序通常是根域 (http://domain.com/customapp) 下的子应用程序。应用程序文件是相同的(aspx、ascx、样式表、图像等)。唯一不同的是每个客户端的 web.config 文件。随着应用程序开发的不断发展,我必须更新每个目录的应用程序,这显然变得乏味。我正在尝试想出一种方法来使应用程序保持最新状态。我的第一个是将应用程序放入单个物理路径并创建指向该路径的多个应用程序(此方法的问题是我不能拥有不同的 web.config 文件)。我很好奇其他人在这种情况下使用什么解决方案......

I have a custom ASP.NET application that I utilize for several clients that I host. Each client has a separate domain and the application is normally a child application under the root domain (http://domain.com/customapp). The application files are the same (aspx, ascx, style sheets, images, etc.). The only thing different is the web.config file for each client. As development of the application continues to evolve, I have to update the application for each directory and this obviously becoming tedious. I am trying to come up with a method keep the application up to date. My first though is placing the application into a single physical path and creating multiple applications pointing to that path (the problem with this method is I can't have different web.config files). I am curious as to what solution others are using in this scenario...

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

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

发布评论

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

评论(2

人│生佛魔见 2024-10-15 05:13:11

如果您想完全在 Visual Studio 中处理此问题,VS2010 提供 web.config 转换 这可以解决你的问题。

简而言之,为每个站点创建一个构建配置(在 VS 中,选择“构建|配置管理器...”)。为每个客户端添加一个 web.config 转换,该转换仅指定每个应用程序所需的差异。

我使用它来区分开发、暂存和发布配置 - 每个转换都会调整连接字符串、应用程序设置等 - 并且它在 Visual Studio 中以及通过 MSBuild 部署时都运行得很好。

另请注意,web.config 设置由 IIS 应用程序继承。因此,如果您有根站点

/root

和客户端应用程序,

/root/client1
/root/client2
...

则可以将特定于客户端的配置设置放置在每个特定于客户端的文件夹中的 web.config 中,并将全局设置放置在根文件夹中的 web.config 中。

If you want to handle this entirely in Visual Studio, VS2010 offers web.config transforms which could solve your problem.

In a nutshell, create a build configuration (In VS, select Build|Configuration Manager...) for each site. Add a web.config transform for each client, which only specifies the differences required for each application.

I use this for differentiating between development, staging and release configurations - each transform adjusts the connection string, app settings, etc - and it works quite well both within Visual Studio and when deploying via MSBuild.

Also, note that web.config settings are inherited by IIS applications. So, if you have a root site

/root

and client apps

/root/client1
/root/client2
...

you could place the client-specific config settings in a web.config in each client-specific folder, and global settings a web.config in the root folder.

能怎样 2024-10-15 05:13:11

您能否将 web.config 内容移至数据库并根据引用的域有条件地加载它?

    Select Case Request.Url.Host.ToLowerInvariant()
        Case "xyz.com", "www.xyz.com"
            'Load XYZ stuff'
        Case "abc.com", "www.abc.com"
            'Load ABC stuff'
        Case Else
            'Throw an error probably'
    End Select

更好的是,将您的域作为密钥存储在数据库中,这样您就不必接触代码。

Can you just move your web.config content to a database and load it conditionally based on the domain that was referenced?

    Select Case Request.Url.Host.ToLowerInvariant()
        Case "xyz.com", "www.xyz.com"
            'Load XYZ stuff'
        Case "abc.com", "www.abc.com"
            'Load ABC stuff'
        Case Else
            'Throw an error probably'
    End Select

Even better, store your domains in the database as keys so that you don't ever have to touch the code.

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