Swagger gives me HTTP Error 403.14 - Forbidden

12,116

Solution 1

I just had the same problem. It worked fine when I deployed my app to Azure, but when I started it locally, Swagger just wouldn't show up just as described above. Reverting to a previous version I knew was working before also didn't help, so it seemed to have something to do with IIS express. I'm not entirely sure what was causing the issue (I had changed some SSL related settings), but when I deleted the .vs folder (which contains the applicationhost.config file) and restarted Visual Studio, it started working again.

Solution 2

It's an old question, but it would be helpful for someone facing the same problem

If your project has a folder named swagger at root level, it conflicts and you will be not able to access swagger by hostname/swagger.

The solution is to just rename the Swagger folder to another name, then it works.

Solution 3

I was having the same issue. After trying few things it still didn't work. Then, I tried changing the Web API application port number as suggested at the link below and it worked. I'm not sure what caused the issue.

https://github.com/domaindrivendev/Swashbuckle/issues/618

Solution 4

I have this issue and it's route and static directory conflict. For Web Api 2, make sure you don't have a static folder named 'swagger'. For .NET Core, remove folder named 'swagger' in wwwroot.

Share:
12,116
Chris Knight
Author by

Chris Knight

Updated on July 27, 2022

Comments

  • Chris Knight
    Chris Knight over 1 year

    I am trying to use Swagger with Web API. I am just using the "Azure API App" template from the ASP.NET 4.6 templates installed with Visual Studio, which includes the Swashbuckle.Core and the SwaggerConfig.cs. The API works fine (I am able to call it successfully), but if I try to go to "http://mybaseurl/swagger/", I get this error:

    HTTP Error 403.14 - Forbidden The Web server is configured to not list the contents of this directory.

    It seems like Swagger is not getting loaded or something. Anyone else get this before? I can't seem to get around this. Thank you, and please let me know if I can provide more details.

    Here is what my SwaggerConfig.cs looks like:

    [assembly: PreApplicationStartMethod(typeof(SwaggerConfig), "Register")]
    
    namespace With.Api
    {
        public class SwaggerConfig
        {
            public static void Register(HttpConfiguration config)
            {
                var thisAssembly = typeof(SwaggerConfig).Assembly;
    
                config.EnableSwagger(c =>
                {
                    c.SingleApiVersion("v1", "With.Api");
                })
                .EnableSwaggerUi();
            }
        }
    }