我有一个源web.config文件和一个web.config为我的生产环境手工编辑的目标文件。
是否有实用程序、工具或方法可以在两个文件之间自动创建 Web 配置转换?
我需要通过配置文件阻止一个巨大的IP列表
<security>
<ipSecurity allowUnlisted="true">
<clear />
<add ipAddress="1.0.1.0" subnetMask="255.255.255.0" />
<add ipAddress="1.0.2.0" subnetMask="255.255.254.0" />
<add ipAddress="1.0.8.0" subnetMask="255.255.248.0" />
<add ipAddress="1.0.32.0" subnetMask="255.255.224.0" />
...
</ipSecurity>
</security>
Run Code Online (Sandbox Code Playgroud)
是否可以将web.config中的安全性部分添加到外部文件中?
我的 web.config 的一部分如下所示:
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<remove name="WebDAVModule" />
<add name="ImageResizingModule" type="ImageResizer.InterceptModule" />
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler" />
<add name="Prerender" type="Prerender.io.PrerenderModule, Prerender.io, Version=1.0.0.2, Culture=neutral, PublicKeyToken=null" />
</modules>
Run Code Online (Sandbox Code Playgroud)
我想摆脱这条线
我已经尝试过了,但它摆脱了除 WebDav 之外的所有内容
<system.webServer>
<rewrite xdt:Transform="Replace">
<rules>
</rules>
</rewrite>
<modules runAllManagedModulesForAllRequests="true">
<add name="Prerender" type="Prerender.io.PrerenderModule, Prerender.io, Version=1.0.0.2, Culture=neutral, PublicKeyToken=null"
xdt:Transform="RemoveAll" />
</modules
Run Code Online (Sandbox Code Playgroud)
我想在发布时将以下内容添加到 web 配置中:
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Strict-Transport-Security" value="max-age=16070400; includeSubDomains" xdt:Transform="Insert" />
</customHeaders>
</httpProtocol>
</system.webServer>
Run Code Online (Sandbox Code Playgroud)
默认 Web 配置中没有任何自定义标头,因此在发布时出现错误: No element in the source document matches '/configuration/system.webServer/httpProtocol/customHeaders'.
我可以修复它,只需将空元素添加到 web.config 中,如下所示:
<httpProtocol>
<customHeaders>
</customHeaders>
</httpProtocol>
Run Code Online (Sandbox Code Playgroud)
但是,感觉这不是正确的方法。
有没有更正确的方法在变换上构建元素树?
我想将appsettings本地 web.config 文件的部分从本地开发工作的一堆单独设置转换为configSource用于发布到客户端服务器的文件路径属性。
基本上是这样的:
<appSettings>
<add key="setting1" value="devVal1"></add>
<add key="setting2" value="devVal2"></add>
<add key="setting3" value="devVal3"></add>
</appSettings>
Run Code Online (Sandbox Code Playgroud)
对此:
<appSettings configSource="clientSettings.config" />
Run Code Online (Sandbox Code Playgroud)
此部分解决方案添加了 configSource 属性。
<appSettings xdt:Transform="SetAttributes(configSource)" configSource="clientSettings.config"/>
Run Code Online (Sandbox Code Playgroud)
但我不确定如何删除所有单独的设置(我认为 configSource 无论如何都会覆盖它们,但我宁愿根本不存在它们,以避免在我的每个客户的网络中都有不相关的开发设置.config 文件)
我有一个Web项目,该项目使用位于客户端->终结点->地址部分下的Web.config文件中的两个服务终结点
我在“章鱼变量”部分找到了以下内容,但似乎找不到像平时一样如何使用和实际变量解决更改的任何参考
我正在使用用于章鱼的webui
http:// {服务器名称} / app#/ projects / {项目名称} /变量
我试图像这样分配变量,但是值从未更新,原始条目如下所示
<endpoint address="http://services-test.example.com/test.svc/soap" binding="basicHttpBinding" bindingConfiguration="soap" contract="test.service" name="soap" />
Name Address Instance
Endpoint[A].Address test-service-a.example.com 1
Endpoint[B].Address test-service-b.example.com 2
Run Code Online (Sandbox Code Playgroud)
使用章鱼变量是否有可能做到这一点?(我知道可以使用常规的Web.config转换来完成此操作,因为我们已经这样做了)。
如果可能的话,正确的替换值是多少
端点地址
是,我将如何针对多个不同的端点地址完成此操作?
我有一个 webb 应用程序,我想利用 web.debug.config 文件,以便在调试时使用测试数据库。这对我不起作用。我的 web.debig.config 中有这个。
<connectionStrings>
<add name="connStr"
connectionString="Data Source=LocalSqlserverName;Initial Catalog=testdb;Persist Security Info=True;User ID=Myusername;Password=mypassword"
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>
Run Code Online (Sandbox Code Playgroud)
在我的 web.config 文件中,这个连接字符串指向另一个数据库服务器。但是当我调试时,我可以看到使用了 web.config 文件中的连接字符串,而不是 web.debug.config 中的连接字符串。我在这里做错了什么?
我之前从未使用过转换.我试图在我的ASP.NET MVC 5项目中使用两个不同的连接字符串.
以下是我的Web.config文件的摘要:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<!-- more -->
<connectionStrings>
<add name="ChopsticksDBContext" providerName="System.Data.SqlClient" connectionString="Data Source=tcp:s10.winhost.com;Initial Catalog=DB_XXX31_kieXXX;User ID=DB_XXX31_kieXXX_user;Password=XXXX;Integrated Security=False;" />
</connectionStrings>
</configuration>
Run Code Online (Sandbox Code Playgroud)
我在Web.Debug.config文件中添加了以下标记:
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<!-- more -->
<connectionStrings>
<add name="ChopsticksDBContext"
providerName="System.Data.SqlClient"
connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-KiewicWebsite-20131214161254;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-KiewicWebsite-20131214161254.mdf"
xdt:Transform="Replace" xdt:Locator="Match(name)"/>
</connectionStrings>
</configuration>
Run Code Online (Sandbox Code Playgroud)
我在调试模式下运行我的项目,我仍然获得连接字符串的原始值.
知道什么可能是错的吗?
我有AngularJS控制器和服务,它们引用服务器1中托管的一部分代码。因此,要获取或发布数据,我必须引用
var getUsers = $resource('http://localhost:2211/projectname/users/getusers',
{
id: viewModel.user.Id
});
getUsers.get(function (result: users.usersResource)
{
if(result != null)
{
$scope.viewModel.firstName = result.firstName;
}
}
Run Code Online (Sandbox Code Playgroud)
我的问题是如何设置web.config文件来保存上面提到的网址,并从我的控制器或服务页面调用它,而不是每次执行发布或获取时都对网址进行硬编码。
请帮忙。