0

I have a problem when deploying an ASP.NET Core Web API to my IIS. I can't access scalar UI using '/scalar/v1' everything just white.

When I run it locally, everything is ok, I can test my API directly or using Postman. It just happens when deploying to IIS.

Program.cs

builder.Services.AddSwaggerGen();

var app = builder.Build();

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
    app.UseSwagger(options =>
    {
        options.RouteTemplate = "/openapi/{documentName}.json";        
    });
    app.MapScalarApiReference(options =>
    {
        options.Title = "My - API";        
    });
}

app.UseHttpsRedirection();
app.UseAuthentication();
app.UseAuthorization();

app.MapControllers();

app.Run();

white-blank screen

I tried to include and remove the environment checking since this was checked as an answer but I'm still having the same problem

// Configure the HTTP request pipeline.
//if (app.Environment.IsDevelopment() || app.Environment.IsProduction())
//{
    app.UseSwagger(options =>
    {
        options.RouteTemplate = "/openapi/{documentName}.json";        
    });
    app.MapScalarApiReference(options =>
    {
        options.Title = "CPS - API";        
    });
//}

1 Answer 1

-3

You should remove Swagger and add MapOpenApi. Use something like this

if (app.Environment.IsDevelopment())
{
    app.MapOpenApi();
    app.MapScalarApiReference(options =>
    {
        options
            .WithTitle("CPS - API");
    });
}

Note: This is tested in .NET 9 only

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.