Question Asp core does not support multiple apps in the same app pool

Anonymous

Well-known member
Joined
Sep 29, 2020
Messages
84
Programming Experience
Beginner
I am trying to learn API development. I am using .net 3.1(my org uses VS 2019 and it is only showing me this framework). I have chosen API template(that has a sample Weatherforecast API). Upon executing it,I can see plain JSON in chrome but I wanted swagger UI).
I am getting the following error -

I can see the swagger homepage but I get a Failed to Load API, error code 500 Error

I navigated to this error and it says

C#:
asp.net core does not support multiple apps in the same app pool Please assign the application /LM/W3SVC/ROOT/2/SWAGGER to a different IIS application pool"
Though, I am only using the default VS API template.

I installed -

Swashuckle.AspNetCore(6.5.0)

This is my startup.cs

C#:
 public void ConfigureServices(IServiceCollection services)
        {

            services.AddControllers();
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo { Title = "CreateAPIPRactice", Version = "v1" });
            });

 
     public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
    if (env.IsDevelopment())
    {
        app.UseDeveloperExceptionPage();
        app.UseSwagger();
        app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "CreateAPIPRactice v1");
         c.RoutePrefix= "";
});
    }
}

I added swagger in launchsettings.json file as well
C#:
 "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "launchUrl": "swagger",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "CreateAPIPRactice": {
      "commandName": "Project",
      "dotnetRunMessages": "true",
      "launchBrowser": true,
      "launchUrl": "swagger",
      "applicationUrl": "https://localhost:5001;http://localhost:5000",
      "environmentVariables": {

This is the properties window

1701530206674.png


The rest of the code is the default VS sample code.

C#:
  [ApiController]
    [Route("[controller]")]
    public class WeatherForecastController : ControllerBase
    {
        private static readonly string[] Summaries = new[]
        {
            "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
        };

        private readonly ILogger<WeatherForecastController> _logger;

        public WeatherForecastController(ILogger<WeatherForecastController> logger)
        {
            _logger = logger;
        }

        [HttpGet]
        public IEnumerable<WeatherForecast> Get()
        {
            var rng = new Random();
            return Enumerable.Range(1, 5).Select(index => new WeatherForecast
            {
                Date = DateTime.Now.AddDays(index),
                TemperatureC = rng.Next(-20, 55),
                Summary = Summaries[rng.Next(Summaries.Length)]
            })
            .ToArray();
        }
    }
}
 
Last edited:

Latest posts

Back
Top Bottom