通过代码设置会员服务的连接字符串
我有一个 ASP.NET Web 项目和一个通过 web.config 配置的成员资格提供程序。它完全正常工作,所以没有问题。
我们有一个有很多用户的旧系统,因此我想创建一个可以在此 ASP.NET 项目中创建用户的类库,但由于它是一个类库,所以它不能有自己的 app.config 文件。
是否可以通过代码以某种方式设置所有这些信息?
I have an ASP.NET web project and a membership provider configured via my web.config. Its fully working so no problem there.
We have an older system with a lot of users and I would therefor like to create a class library that can create users in this ASP.NET project but since its a class library it cannot have its own app.config-file.
is it possible to set all this information via code somehow?
<membership defaultProvider="ShidMembershipProvider">
<providers>
<clear/>
<add name="ShidMembershipProvider" type="SundaHus.AspNet.Membership.ShidMembershipProvider" connectionStringName="ShidConnectionString" enablePasswordRetrieval="true" enablePasswordReset="true" requiersQuestionAndAnswer="true" applicationName="ECB3-development" minRequiredPasswordLength="5"/>
</providers>
</membership>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您有一个定制的会员资格提供商吗?这会连接到您自己的自定义数据库吗?您应该能够为您的代码指向该数据库。或者,如果您只是从基类继承功能,您也可以尝试重写 Initialize 方法,查找连接字符串,并将值更改为其他值。
You have a custom membership provider it looks like? This connects to your own custom database? You should be able to just point to that database for your code. Or, if you just inherit the functionality from the base class, you can also try overriding the Initialize method, look for the connection string, and change the value to something else.