如何将一个配置文件的设置放到其他Web配置文件中? [英] How to put the settings of one config file to other web config file?
本文介绍了如何将一个配置文件的设置放到其他Web配置文件中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我要放在第二个网页配置中的第一个webconfig
注意:我有2个项目
--- -1 ----
<? xml version = < span class =code-keyword> 1.0 ? >
< configuration xmlns = http://schemas.microsoft.com/.NetConfiguration/v2 .0 >
< connectionStrings >
< add name = ConnectionString connectionString = 数据源=。 \ SQLEXPRESS; AttachDbFilename = | DataDirectory | \Database.mdf; Integrated Security = True; User Instance = True providerName = System.Data.SqlClient / >
< / connectionStrings >
< system.web >
< 授权 >
< 允许 用户 = ? / >
< allow 角色 = admin < span class =code-keyword> / >
< / authorization >
< roleManager 已启用 = true / >
< 身份验证 mode = 表单 / >
<! -
设置编译debug =true将调试
符号插入编译页面。由于此
会影响性能,因此在开发期间将此值设置为true仅
。
- >
< 编译 debug = true targetFramework = 4.0 >
< / compilation > ;
< pages controlRenderingCompatibilityVersion = 3.5 clientIDMode = AutoID / > < / system。网络 >
< system.web >
< anonymousIdentification 已启用 = true / >
< 个人资料 已启用 = true >
< 属性 >
< add name = SCart serializeAs = 二进制 类型 = ShoppingCartExample.Cart allowAnonymous = true / >
< / properties >
< / profile >
< /system.web >
< / configuration >
---- 2 ----
<? xml version = 1.0 ? >
<! -
有关如何配置ASP.NET应用程序的更多信息,请访问
http://go.microsoft.com/fwlink/?LinkId=169433
- >
< configuration >
< connectionStrings >
< add name = ApplicationServices connectionString = < span class =code-keyword> data source = .\SQLEXPRESS; Integrated Security = SSPI; AttachDBFilename = | DataDirectory | \ aspnetdb.mdf; User Instance = true providerName = System.Data .SqlClient / >
< / connectionStrings >
< system.web >
< 编译 debug = true targetFramework = 4.0 / >
< 身份验证 mode = 表单 >
< 表格 loginUrl = 〜/ Account / Login.aspx < span class =code-attribute> timeout = 2880 / >
< / authentication >
< 成员资格 >
< 提供商 >
< clear / >
< add < span class =code-attribute> name = AspNetSqlMembershipProvider 类型 = System.Web.Security.SqlMembership提供者 connectionStringName = ApplicationServices enablePasswordRetrieval = false enablePasswordReset = true requiresQuestionAndAnswer = false requiresUniqueEmail = false maxInvalidPasswordAttempts = 5 minRequiredPasswordLength = 6 minRequiredNonalphanumericCharacters = 0 passwordAttemptWindow = 10 applicationName = / / >
< / providers >
< / membership >
< 个人资料 >
< 提供商 >
< clear / >
< ; add name < span class =code-keyword> = AspNetSqlProfileProvider type = System.Web.Profile.SqlProfileProvider connectionStringName = ApplicationServices applicationName = / / >
< / providers >
< span class =code-keyword>< / profile >
< roleManager 已启用 = false >
< 提供商 >
< clear / >
< add name = AspNetSqlRoleProvider type = System.Web.Security .SqlRoleProvider connectionStringName = ApplicationServices applicationName = / / >
< add 名称 = AspNetWindowsTokenRoleProvider type = System.Web.Security.WindowsTokenRoleProvider applicationName = / / >
< / providers >
< / roleManager >
< / system.web >
< system.webServer >
< modules runAllManagedModulesForAllRequests = true / >
< / system.webServer >
< / configuration >
解决方案
请参阅这里 [ ^ ]
和这里 [ ^ ]
和其中 [ ^ ]
希望这个帮助
This the 1st webconfig that i want to put in the second web config
note: I have 2 projects
----1----
<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<connectionStrings>
<add name="ConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
<authorization>
<allow users="?"/>
<allow roles="admin"/>
</authorization>
<roleManager enabled="true"/>
<authentication mode="Forms"/>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
-->
<compilation debug="true" targetFramework="4.0">
</compilation>
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/></system.web>
<system.web>
<anonymousIdentification enabled="true"/>
<profile enabled="true">
<properties>
<add name="SCart" serializeAs="Binary" type="ShoppingCartExample.Cart" allowAnonymous="true"/>
</properties>
</profile>
</system.web>
</configuration>
----2----
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<connectionStrings>
<add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
<authentication mode="Forms">
<forms loginUrl="~/Account/Login.aspx" timeout="2880"/>
</authentication>
<membership>
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/"/>
</providers>
</membership>
<profile>
<providers>
<clear/>
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/"/>
</providers>
</profile>
<roleManager enabled="false">
<providers>
<clear/>
<add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/"/>
<add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/"/>
</providers>
</roleManager>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
解决方案
See here[^]
and here[^]
and here[^]
Hopefully this helps.
这篇关于如何将一个配置文件的设置放到其他Web配置文件中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文