Use a connection provider instead. Far easier and it still allows NHibernate to control the connection which is far better as well.
Code:
using System;
using System.Data;
using NHibernate.Connection;
namespace Fake.Data {
public class TestConnectionProvider : ConnectionProvider {
public override IDbConnection GetConnection() {
string dbName = (HttpContext.Current.Items["DB_NAME"] ?? Settings.CommonDatabaseName);
IDbConnection connection = base.Driver.CreateConnection();
connection.ConnectionString = String.Format(base.ConnectionString, dbName);
connection.Open();
return connection;
}
}
}