开发者

ASP.NET user database without web.config connection strings

开发者 https://www.devze.com 2023-01-03 16:39 出处:网络
I\'m wondering whether it\'s possible to use built in ASP.NET application services (aspnet_user, aspnet_role etc table) without specifying a connection string in a web.config.

I'm wondering whether it's possible to use built in ASP.NET application services (aspnet_user, aspnet_role etc table) without specifying a connection string in a web.config.

At the moment I store connection strings externally, but I keep finding hard-coded开发者_开发问答 connection strings all over the web.config xml, various providers etc. It's driving me crazy.

Thank you


You can write your own provider via overriding already existed, built-in class so it will read it's connection string from somewhere else:

public class MyMembershiProvider : SqlMembershiProvider
{
    public override void Initialize(string name, NameValueCollection config)
    {
        config["connectionString"] = "what ever you want";

        base.Initialize(name, config);
    }
}
0

精彩评论

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