开发者

moving asp.net membership specific settings to a separate config file

Is it possible to move the asp.net membership/role settings to a separate config file. This is helpful for custom membership providers.

<authentication  mode="Forms">
  <forms loginUrl="~/Login.aspx" timeout="144600" slidingExpiration="true">
</authentication>
<membership defaultProvider="TestMembership">
   <providers>
      <add name="TestMembership" type="Test.Membership.TestMembership">
   </providers>
</membership>
<roleManager enabled="true" defaultProvider="TestRole"
             cacheRolesInCookie="true" cookieName=".Test" cookieTimeout="1440"
             cookiePath="/开发者_运维知识库">
   <providers>
      <add name="TestRole" type="Test.Membership.TestRole" />
   </providers>
</roleManager>


Any .NET configuration section can be externalized - try this:

<authentication configSource="auth.config" />
<membership configSource="members.config" />
<roleManager configSource="roles.config" />

or whatever names you want to use.

The individual files need to contain the whole section that you've externalized:

auth.config

<?xml version="1.0" encoding="utf-8"?>
<authentication  mode="Forms">
  <forms loginUrl="~/Login.aspx" timeout="144600" slidingExpiration="true">
</authentication>

members.config

<?xml version="1.0" encoding="utf-8"?>
<membership defaultProvider="TestMembership">
   <providers>
      <add name="TestMembership" type="Test.Membership.TestMembership">
   </providers>
</membership>

roles.config

<?xml version="1.0" encoding="utf-8"?>
<roleManager enabled="true" defaultProvider="TestRole"
             cacheRolesInCookie="true" cookieName=".Test" cookieTimeout="1440"
             cookiePath="/">
   <providers>
      <add name="TestRole" type="Test.Membership.TestRole" />
   </providers>
</roleManager>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜