Swashbuckle.webapi: IIS 7.5 Gives 404 Errors

Created on 10 Mar 2015  路  8Comments  路  Source: domaindrivendev/Swashbuckle.WebApi

I set up a Web API project locally and ran against IIS Express. it worked fine and I was able to browse to the swagger documentation. when I deploy to an IIS server I got 404 errors. what's different between running on IIS Express and regular IIS?

I've tried hitting the Web API endpoint directly with no luck. I also tried navigating to the swagger documentation with no luck. I just use the default route configuration created by the Visual Studio project.

Most helpful comment

I think this may have something to do with the use of "WebActivatorEx" to automagically wire up the SB routes on application startup. It seems other people have also encountered issues with WebActivatorEx and IIS 7.5 - http://stackoverflow.com/questions/7716880/webactivator-doesnt-run-on-iis-7

You can try working around this by removing the dependency on WebActivatorEx and initialize SB manually from Global.asax ...

In SwaggerConfig.cs, remove the following line:

[assembly: PreApplicationStartMethod(typeof(SwaggerConfig), "Register")]

In the same file, update the Register method to accept a HttpConfiguration instance

public static void Register(HttpConfiguration httpConfig)

Also replace the reference to GlobalConfiguration.Configuration with the provided httpConfig instance

Finally, invoke the Register method directly from your Global.asax

protected void Application_Start()
{
    SwaggerConfig.Register(GlobalConfiguration.Configuration);            
    GlobalConfiguration.Configure(WebApiConfig.Register);
}

Let me know if this helps?

All 8 comments

I think this may have something to do with the use of "WebActivatorEx" to automagically wire up the SB routes on application startup. It seems other people have also encountered issues with WebActivatorEx and IIS 7.5 - http://stackoverflow.com/questions/7716880/webactivator-doesnt-run-on-iis-7

You can try working around this by removing the dependency on WebActivatorEx and initialize SB manually from Global.asax ...

In SwaggerConfig.cs, remove the following line:

[assembly: PreApplicationStartMethod(typeof(SwaggerConfig), "Register")]

In the same file, update the Register method to accept a HttpConfiguration instance

public static void Register(HttpConfiguration httpConfig)

Also replace the reference to GlobalConfiguration.Configuration with the provided httpConfig instance

Finally, invoke the Register method directly from your Global.asax

protected void Application_Start()
{
    SwaggerConfig.Register(GlobalConfiguration.Configuration);            
    GlobalConfiguration.Configure(WebApiConfig.Register);
}

Let me know if this helps?

That got me a lot further. Thank you! The swagger page comes up when I go to http://webserver01:8510/swagger but it complains of an error in the lower right corner (I click it and gives a 500 error). I am just using the default route for my web service. If I go to http://webserver01:8510/api/GetListItems I get XML response data from my web service. I am also able to use the try it out feature on the swagger page and it successfully brings back a response.

The error doesn't seem to be affecting anything at this point but curious as to what it might mean?

The server is not publicly visible. Could the error be related to a validator on the Internet trying to reach our non-local machine? Maybe a setting to disable the check?

I'm convinced it's the validatorUrl option I need to set. Just not seeing it in the code completion. How do I go about setting it in swashbuckle?

https://github.com/swagger-api/swagger-ui#parameters

See the section entitled "SetValidatorUrl/DisableValidator" in the readme

Domain, I did tried your suggestion but doesn't work in my case.
Same configuration work well in IIS Express and in Azure Web Application but not in my local IIS 7.5

Any advice?

Any ?

lakeba if [assembly: PreApplicationStartMethod(typeof(SwaggerConfig), "Register")] is in your SwaggerConfig then you don't need the global.asax.cs entry

I am having the same problem and manually calling register isn't fixing it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

niemyjski picture niemyjski  路  3Comments

whippet-rider picture whippet-rider  路  5Comments

qwertykeith picture qwertykeith  路  5Comments

Misiu picture Misiu  路  3Comments

djem3000 picture djem3000  路  5Comments