从webconfig获取连接字符串 [英] Getting connection string from webconfig

查看:112
本文介绍了从webconfig获取连接字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建自定义.net成员资格提供程序.我了解基础知识,并使用相关方法创建了一个新的类库(因为我想重用此库).

目前,我已在web.config中注册了我的自定义提供程序,如果我在这些方法上添加了一个断点,则它们将被调用.我的问题是,如何从程序集中访问连接字符串?当我在web.config中添加我的提供程序时,我引用了一个连接字符串.这是我目前拥有的:

I am creating a custom .net membership provider. I understand the basics and have created a new class library(as I want to reuse this) with the relevant methods.

At the moment I have registered my custom provider in the web.config and if I add a break point to the methods, they are being called. My question though, is how can I access the connection string from my assembly? I reference a connection string when I add my provider in the web.config. This is what I have currently:

<add name="DWMembership" type="DWMembership.Authentication" connectionStringName="ApplicationServices"

             enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false"

             maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"

             applicationName="/" />



任何帮助将是巨大的!在此先感谢您.



Any help would be great! Thanks in advance.

推荐答案

真正的问题是您可以使用google吗?

http://msdn.microsoft.com/en-us/library/ms178411.aspx#Y193 [^ ]
The REAL question is can you use google?

http://msdn.microsoft.com/en-us/library/ms178411.aspx#Y193[^]


好吧,经过一番游戏之后,我发现了如何获得它.如果您覆盖Initialize方法,则解析的参数之一就是添加提供程序时输入的值的集合.
Ok, after some playing around I found out how to get it. If you override the Initialize method one of the parameters parsed is the collection of values you entered when adding the provider.


这篇关于从webconfig获取连接字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆