ASP.NET user database without web.config connectio

2019-07-28 23:35发布

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

1条回答
We Are One
2楼-- · 2019-07-28 23:44

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);
    }
}
查看更多
登录 后发表回答