Search code examples
c#.netasp.net-web-apimonomonodevelop

How to get Swashbuckle / Swagger working on the Mono (.NET) Framework?


In MonoDevelop I started a new WebApi project. The WebApi application is working as expected. In addition to the default WebApi project I added Swashbuckle / Swagger for auto-generating documentation of the API. When I navigate to swagger (http://localhost/swagger) an 404 error occured. In the documentation I found I need to add some configuration lines to the Web.Config.

<system.webServer>
  <modules runAllManagedModulesForAllRequests="true">
</modules>

https://github.com/domaindrivendev/Swashbuckle/blob/master/README.md#page-not-found-when-accessing-the-ui

After this change nothing changed. The project is running on the Mono XSP4 webserver. Does anyone know how to solve this issue?

Thanks a lot, Jordy


Solution

  • Found the solution:

    https://github.com/domaindrivendev/Swashbuckle/issues/555#issuecomment-153493068

    Add the following lines to your Web.Config file.

    <dependentAssembly>
        <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="4.0.0.0" />
    </dependentAssembly>