RicoSuter / NSwag

The Swagger/OpenAPI toolchain for .NET, ASP.NET Core and TypeScript.
http://NSwag.org
MIT License
6.78k stars 1.29k forks source link

OWIN Middleware did not work #1915

Closed chucklu closed 5 years ago

chucklu commented 5 years ago

Hi, I am trying to configure NSwag according the tutorial https://github.com/RSuter/NSwag/wiki/OWIN-Middleware. However, after I did everything I can do, when I try to access my http://myserver/swagger/ .I just got a 500 error.

<h4>Detailed Error Information:</h4>
                    <div id="details-left">
                        <table border="0" cellpadding="0" cellspacing="0">
                            <tr class="alt">
                                <th>Module</th>
                                <td>&nbsp;&nbsp;&nbsp;ManagedPipelineHandler</td>
                            </tr>
                            <tr>
                                <th>Notification</th>
                                <td>&nbsp;&nbsp;&nbsp;ExecuteRequestHandler</td>
                            </tr>
                            <tr class="alt">
                                <th>Handler</th>
                                <td>&nbsp;&nbsp;&nbsp;NSwag</td>
                            </tr>
                            <tr>
                                <th>Error Code</th>
                                <td>&nbsp;&nbsp;&nbsp;0x800703e9</td>
                            </tr>
                        </table>
                    </div>
                    <div id="details-right">
                        <table border="0" cellpadding="0" cellspacing="0">
                            <tr class="alt">
                                <th>Requested URL</th>
                                <td>&nbsp;&nbsp;&nbsp;http://localhost:80/Chuck_WebApi/swagger/</td>
                            </tr>
                            <tr>
                                <th>Physical Path</th>
                                <td>&nbsp;&nbsp;&nbsp;C:\Users\clu\source\repos\WebApi\WebApi\swagger\</td>
                            </tr>
                            <tr class="alt">
                                <th>Logon Method</th>
                                <td>&nbsp;&nbsp;&nbsp;Anonymous</td>
                            </tr>
                            <tr>
                                <th>Logon User</th>
                                <td>&nbsp;&nbsp;&nbsp;Anonymous</td>
                            </tr>
                            <tr class="alt">
                                <th>Request Tracing Directory</th>
                                <td>&nbsp;&nbsp;&nbsp;C:\inetpub\logs\FailedReqLogFiles</td>
                            </tr>
                        </table>
                        <div class="clear"></div>
chucklu commented 5 years ago

My demo project is on https://github.com/ChuckTest/AspNetWebApi2/ repository, branch owin-middleware.

https://github.com/ChuckTest/AspNetWebApi2/commits/owin-middleware

I am not sure if I have made something wrong, could you please take a look at it. Thanks in advance!

chucklu commented 5 years ago

I have tried with failed request tracing https://docs.microsoft.com/en-us/iis/troubleshoot/using-failed-request-tracing/troubleshooting-failed-requests-using-tracing-in-iis-85

logs.zip you can check the log by Internet Explorer However the status is 200 instead of 500 image

What I got when I access the url from chrome is: image

chucklu commented 5 years ago

I find this problem caused by configuration problem. Configure the routing of the Swagger requests There are two ways to do this: I configure both of them, when I choose Pipe all request to the .NET pipeline, it works.

However, when I use second, Pipe only the Swagger request to the specific middlewares, still same error.

RicoSuter commented 5 years ago

Thanks for the update, feel free to update the owin wiki if it may help others

gitlsl commented 5 years ago

I follow the steps by https://github.com/RSuter/NSwag/wiki/OWIN-Middleware , and add in the app.config still get error ,can not get swagger.json
My program is is Owin base on console ,are there any thing I miss?

chucklu commented 5 years ago

@gitlsl You can upload your demo project to github, then I can check it for you. Or you can check the sample project first https://github.com/RSuter/NSwag/tree/master/samples/NSwag.Sample.NetOwinMiddleware