.NET 4.0 和他的 Web.Config 的 XDT

发布于 2024-09-25 00:02:48 字数 1609 浏览 0 评论 0原文

我正在尝试在 4.0 Web 应用程序中使用 XDT,但我只是不知道如何使用!我知道这可能很奇怪(至少,从那时起我读过的所有帖子,每个人似乎都很容易做到这一点,但嗯,不是我!!)。没有任何作用。这是我尝试过的:

这是我的 Web.Debug.Config :

<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">

  <appSettings xdt:Transform="Replace">
    <add key="ConnectionString.SQL Server (SqlClient)"
     value="data source=test;initial catalog=TestDB;User ID=sa;Password=testpsw;persist security info=False;packet size=4096"  />
  </appSettings>

  <connectionStrings xdt:Transform="Replace">
    <add name="ASP.net Authentication"
     connectionString="data source=(local);initial catalog=TestDB;User ID=sa;Password=testpsw;persist security info=False" />
  </connectionStrings>

</configuration>

在我的 web.config 中,我有这个和很多其他东西,但我只想更改这些。

<?xml version="1.0"?>
[...]
<configuration>

  <appSettings>
    <add key="ConnectionString.SQL Server (SqlClient)"
     value="data source=[THIS WILL CHANGE];initial catalog=[THIS WILL CHANGE];User ID=[THIS WILL CHANGE];Password=[THIS WILL CHANGE];persist security info=False;packet size=4096"  />
  </appSettings>

  <connectionStrings>
    <add name="ASP.net Authentication"
     connectionString="data source=[THIS WILL CHANGE];initial catalog=[THIS WILL CHANGE];User ID=[THIS WILL CHANGE];Password=[THIS WILL CHANGE];persist security info=False" />
  </connectionStrings>

</configuration>
[...]

我做错了什么?

注意:我已经阅读了 MSDN 上的帖子,但它对我没有帮助......

I'm trying to use the XDT in a 4.0 web application and I just don't figure out how! I know this is maybe weird (At least, all thread I've read since then, everybody seems to do it easly but hum, not me!!). Nothing working. Here's what I've tryed :

Here's my Web.Debug.Config :

<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">

  <appSettings xdt:Transform="Replace">
    <add key="ConnectionString.SQL Server (SqlClient)"
     value="data source=test;initial catalog=TestDB;User ID=sa;Password=testpsw;persist security info=False;packet size=4096"  />
  </appSettings>

  <connectionStrings xdt:Transform="Replace">
    <add name="ASP.net Authentication"
     connectionString="data source=(local);initial catalog=TestDB;User ID=sa;Password=testpsw;persist security info=False" />
  </connectionStrings>

</configuration>

In my web.config, I've got this and plenty of other things but I just want to change those.

<?xml version="1.0"?>
[...]
<configuration>

  <appSettings>
    <add key="ConnectionString.SQL Server (SqlClient)"
     value="data source=[THIS WILL CHANGE];initial catalog=[THIS WILL CHANGE];User ID=[THIS WILL CHANGE];Password=[THIS WILL CHANGE];persist security info=False;packet size=4096"  />
  </appSettings>

  <connectionStrings>
    <add name="ASP.net Authentication"
     connectionString="data source=[THIS WILL CHANGE];initial catalog=[THIS WILL CHANGE];User ID=[THIS WILL CHANGE];Password=[THIS WILL CHANGE];persist security info=False" />
  </connectionStrings>

</configuration>
[...]

What I'm doing wrong?

Note : I've read the post from MSDN and it do not helped me...

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

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

发布评论

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

评论(1

听,心雨的声音 2024-10-02 00:02:48

要在 Web 应用程序上执行 web.config 转换,您必须部署该项目。右键单击该项目并转到“发布”。

仅在本地构建项目并不能执行转换。

To perform a web.config transformation on a web application, you have to deploy the project. Right click on the project and go to Publish.

Just building a project locally will not perform the transformation.

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