Skip to content

How to use Slik in a .NET 6 Web Api project? #15

Description

@harrison314

I'm trying to create a REST API project using Slik.Cache, code example:

            WebApplicationBuilder builder = WebApplication.CreateBuilder();
            builder.Host.UseSlik(new SlikOptions
            {
                Host = new IPEndPoint(IPAddress.Loopback, 3092),
                Members = new[] { "localhost:3092", "localhost:3093", "localhost:3094" }
            });

            builder.Services.AddControllers();
            // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
            builder.Services.AddEndpointsApiExplorer();
            builder.Services.AddSwaggerGen();

            var app = builder.Build();

            // Configure the HTTP request pipeline.
            if (app.Environment.IsDevelopment())
            {
                app.UseSwagger();
                app.UseSwaggerUI();
            }

            app.UseAuthorization();
            app.MapControllers();

            app.Run();

But I get exception `System.NotSupportedException: 'ConfigureWebHost() is not supported by WebApplicationBuilder.Host. Use the WebApplication returned by WebApplicationBuilder.Build() instead.'.

Do I need to modify something to make it work?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions