1
내가 지속성 ServiceStack의 인증 모듈에 대한 백엔드로하여 MongoDB를 사용하기 위해 노력하고있어에서 MongoDB의를 구성, 그래서 나는 web.config
에서 다음 노드를 추가 한 방법 : 여기 아래servicestack
<connectionStrings>
<add name="myDb" connectionString="mongodb://localhost/mydb?safe=true" />
</connectionStrings>
을 그리고 내 Configure
방법 :
public class MyAppHost : AppHostBase
{
public MyAppHost() : base("My Web Services", typeof(MyService).Assembly)
{
}
public override void Configure(Container container)
{
Plugins.Add(new AuthFeature(() => new AuthUserSession(), new IAuthProvider[] {
new BasicAuthProvider()
}));
Plugins.Add(new RegistrationFeature());
var connectionString = ... // how do I retrieve "mongodb://localhost"?
var dbName = ... // how do I retrieve "mydb"?
var mongoClient = new MongoClient(connectionString);
var server = mongoClient.GetServer();
var db = server.GetDatabase(dbName);
container.Register<ICacheClient>(new MemoryCacheClient());
container.Register<IUserAuthRepository>(new MongoDBAuthRepository(db, true));
}
}
어떻게 web.config
에서 연결 문자열 및 데이터베이스 이름을 검색 할 수 있습니까?