Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Needlessly complex method is suggested for handling the static files #871

Closed
stijnherreman opened this issue Aug 8, 2017 · 3 comments · Fixed by #874
Closed

Needlessly complex method is suggested for handling the static files #871

stijnherreman opened this issue Aug 8, 2017 · 3 comments · Fixed by #874

Comments

@stijnherreman
Copy link
Contributor

stijnherreman commented Aug 8, 2017

https://github.com/RSuter/NSwag/wiki/OwinGlobalAsax suggests adding three handlers to deal with the static files, but this method is needlessly complex. I assume you got your info from https://stackoverflow.com/a/41155395 ?

I've posted a new answer to that question, repeating it here for convenience:

By default, the StaticFile handler is the last handler to be executed. This means that simply intercepting all NSwag requests is enough:

<add name="NSwag" path="swagger" verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />

This also used to be the recommended method by Swashbuckle, until it switched to extensionless URLs. You may notice that ASP.NET is able to handle extensionless URLs with the same type of handler in <add name="ExtensionlessUrlHandler-Integrated-4.0".

In addition, this should also be documented on https://github.com/RSuter/NSwag/wiki/Middlewares because this problem is not limited to the Global.asax method.

@RicoSuter
Copy link
Owner

Can you update the docs/wiki and create a pr for a fix in the sample project?

@stijnherreman
Copy link
Contributor Author

Sure. Should I change both NSwag.Sample.NetGlobalAsax in this repo and the projects in the Samples repo?

@RicoSuter
Copy link
Owner

I'm not sure whether it makes sense to update the Samples repo as it is outdated and we have samples in the NSwag repo itself...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants