I’m trying to migrate from SDK2 to SDK 3.
I’m using ASP.NET Framework 4.
In this link you say under “Connection Lifecycle” that I should connect and dispose inside my global.asax.
How exactly do I dispose of the cluster?
Cluster class doesn’t have a dispose method, and I don’t have access to the return object from the Application_Start in my Application_End method
It’s not like I can define the cluster variable globally (unless I use an Application variable, but even then I was unable to successfully access it from the Application_End to dispose of it or from other pages)
protected void Application_Start(object sender, EventArgs e)
{
// get parameters from web.config
Uri serverURI = new Uri(ConfigurationManager.AppSettings["CouchBase_serverURI"]);
// server authentication
RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Wow6432Node\Test\Couchbase");
if (registryKey != null)
{
string CouchbasePassword = registryKey.GetValue("Couchbase_p").ToString();
var cluster = Cluster.ConnectAsync("couchbase://" + serverURI, "AppUser", CouchbasePassword);
}
}
protected void Session_Start(object sender, EventArgs e)
{
}
protected void Application_BeginRequest(object sender, EventArgs e)
{
}
protected void Application_AuthenticateRequest(object sender, EventArgs e)
{
}
protected void Application_Error(object sender, EventArgs e)
{
}
protected void Session_End(object sender, EventArgs e)
{
}
protected void Application_End(object sender, EventArgs e)
{
}