将从自定义文件读取连接字符串的自定义会员资格提供程序
在我的 Web 应用程序项目中,我使用 MYSQLMemberShipProvider。现在我希望它每次都从外部文件中读取连接字符串,而不是从 web.config 文件中读取连接字符串。
因此,我正在实现自定义成员资格提供程序类,该类继承了 MembershipProvider 类。
但问题是,如果我继承 MembershipProvider 类,那么我必须在自定义会员资格提供程序类中实现它的所有方法,但我想使用 Memebership 的所有其他内置方法。我能做些什么。
我只想添加如下代码:
public class CustomSqlMembershipProvider :MembershipProvider
{
public override void Initialize(string name, NameValueCollection configs)
{
base.Initialize(name, configs);
Connectionstring objProducts = // reading the connection string.
}
}
但是在编译时,它给我错误没有实现继承抽象成员。
请给我建议任何想法。
提前致谢
鲇志
In my web application project I am using MYSQLMemberShipProvider. Now I want that instead of reading the connection string from web.config file, it will read the connection string from external file every time.
So that I am implementing the custom membership provider class, this class inherits the MembershipProvider class.
But the problem is that if I inherits the MembershipProvider class then I have to implement all of its method in my custom membership provider class, But I want to use all other inbuilt methods of Memebership. What can I do.
I only want to add the code like below:
public class CustomSqlMembershipProvider :MembershipProvider
{
public override void Initialize(string name, NameValueCollection configs)
{
base.Initialize(name, configs);
Connectionstring objProducts = // reading the connection string.
}
}
But on compilation it is giving me the error does not implement inherit abstract member.
Please Suggest me any idea.
Thanks in advance
Aayushi
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您从另一个文件读取连接字符串的动机是什么,纯粹是为了为调试/发布环境获取不同的连接字符串吗?如果是这种情况,您可以使用 web.config 转换(如果您有 VS2010)。这是一个非常干净的解决方案,可能对您有用。
What are your motivations for reading in the connection string from another file, is it purely to get a different connection string for debug/release environments? If that is the case you could use web.config transformations if you have VS2010. It is a very clean solution that may be of use to you.