Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
harrison314 opened this issue May 3, 2023 · 1 comment
Open

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

harrison314 opened this issue May 3, 2023 · 1 comment

Comments

@harrison314
Copy link

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?

@Insvald
Copy link
Owner

Insvald commented May 3, 2023

@harrison314 To support WebApplication properly, I need to rewrite the initialization (UseSlik extension method). As a workaround you can continue to use Generic Host in .NET 6. Please consult this article.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants