Migration from 2.x to 3.x


Do you plan to write a document describing how to use new v3 SDK from within global.asax, web.config for a Web Forms .Net application? I can’t find any info how to setup new SDK from within these files anymore.

Also do you plan to upgrade Couchbase ASP.NET (https://github.com/couchbaselabs/couchbase-aspnet) for ASP.Net caching and session management to use the new SDK?

I’m trying myself to find the way to get the collection for a Web Form application from Couchbase.

A simple asxp page is the following:

<%@ Page Language=“C#” EnableSessionState=“ReadOnly” Debug=“true” Async=“true” %>

<%@ Import Namespace=“System.Threading.Tasks” %>
<%@ Import Namespace=“Couchbase” %>
<%@ Import Namespace=“Couchbase.KeyValue” %>
<%@ Import Namespace=“Couchbase.Core.IO.Transcoders” %>
<%@ Import Namespace=“Couchbase.Management.Buckets” %>

async Task<ICluster> InitializeClusterAsync(String Uri, String Bucket, String Username, String Password) {
        var options = new ClusterOptions() {
            KvTimeout = TimeSpan.FromSeconds(5),
            ManagementTimeout = TimeSpan.FromSeconds(12),
            EnableDnsSrvResolution = false,
            UserName = Username,
            Password = Password,
            EnableTls = false,
            EnableConfigPolling = false,
            MaxKvConnections = 25

        var cluster = await Couchbase.Cluster.ConnectAsync(Uri, options).ConfigureAwait(false);
        //await cluster.WaitUntilReadyAsync(TimeSpan.FromSeconds(10)).ConfigureAwait(false);
        return (cluster);

    private async Task<ICouchbaseCollection> GetCollection(ICluster _cluster) {
        var bucket = await _cluster.BucketAsync("default").ConfigureAwait(false);

        return (bucket.DefaultCollection());

var _cluster = InitializeClusterAsync(“couchbase://”, “default”, “xxx”, “yyy”).GetAwaiter().GetResult();
var _collection = GetCollection(_cluster).GetAwaiter().GetResult();


Although the same code is working when i make a desktop app, on the web page is not working. 2 problems:

  1. Althought the bucker “default” exists, i get the exception on the following line
    var bucket = await _cluster.BucketAsync(“default”).ConfigureAwait(false);

[BucketNotFoundException: Bucket with name default does not exist]
Couchbase.Core.d__51.MoveNext() +1213

  1. If i enable the line
    await cluster.WaitUntilReadyAsync(TimeSpan.FromSeconds(10)).ConfigureAwait(false);

I get the following exception
[NotSupportedException: Cluster level WaitUntilReady is only supported by Couchbase Server 6.5 or greater. If you think this exception is caused by another error, please check your SDK logs for detail.]
Couchbase.d__29.MoveNext() +1951

For sure Couchbase is version 6.6 and bucket “default” exists. As i told the same piece of code on a desktop app works on the same server.

Any clue on what is going on? Can we have some solid examples of how we can setup things on Web applications using global.asax, web.config, etc?

I finally managed to make it work. The problem was on the version of some dlls used by Couchbase.NetClient.dll. The error was misleading. As soon as i manually changed the versions to web.config (to the newer ones) it worked.

I tried to make also a version of ASP.Net Output caching with no luck since now. Seems this bug has to be fixed first but i will try further (RawBinaryTranscoder problem). LegacyTranscoder does not seems to do the job.

1 Like

Hello @jzissop -

Yes, master branch in Github is working branch for SDK3 support. Couchbase.Extensions.Caching is largely complete and Session is in progress. Both should be up in NuGet shortly.

Good to hear; there is an outstanding ticket to improve error messaging.

1 Like

As i see only .Net Core will be supported? I managed to build a working classic ASP.Net OutputCacheProvider using the master branch of v3 SDK but a semi-official support would be nice to be added.

Currently we are targeting .NETStandard2.0 which covers .NET Full 4.6.1 and .NET Core 1.0 and greater, including .NET 5.0. Simply put, we need to future proof as some of the older platforms have reached or are nearing there EOL.


1 Like

Yes i understand but i dont think this OutputCacheProvider will work with classic ASP.Net sites, i think it targets specifically .Net v5. Am i wrong?

1 Like

I think there may be some confusion here between .NET Core and ASP.NET Core. You are correct, the OutputCacheProvider is specific to ASP.NET Core. However, the general SDK is compatible with ASP.NET 4.6.1 and later. However, the caching library https://github.com/couchbaselabs/couchbase-aspnet would need to be updated to be compatible with SDK3.


@jzissop -

What @btburnett3 is true; I was confusing the two projects (SDK and Couchbase.Extensions.Caching). The library that Brant mentions (https://github.com/couchbaselabs/couchbase-aspnet) is an older .NET Full framework provider, but could be updated to SDK3 and it would work for your needs.