没有web.config中的连接字符串ASP.NET用户数据库 [英] ASP.NET user database without web.config connection strings

查看:177
本文介绍了没有web.config中的连接字符串ASP.NET用户数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道它是否可以使用内置的ASP.NET应用程序服务(aspnet_user,aspnet_role等表),无一个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.

目前,我存储连接字符串的外部,但我一直寻找的硬codeD连接字符串各地的web.config XML,各供应商等,这是推动我疯了。

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.

感谢您

推荐答案

您可以通过已经存在压倒一切的写自己的供应商,内置类,所以它会读取它的连接字符串从别的地方:

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

这篇关于没有web.config中的连接字符串ASP.NET用户数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆