ASP.NET user database without web.config connection strings

爷,独闯天下 提交于 2019-12-11 06:27:52

问题


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:


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);
    }
}


来源:https://stackoverflow.com/questions/3064787/asp-net-user-database-without-web-config-connection-strings

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!