ASP.NET user database without web.config connection strings
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);
}
}
精彩评论