WebAPI CORS and static files

心已入冬 提交于 2019-12-24 13:29:47

问题


I have a WebApi, it is CORS enabled and works nicely.

I want to add static files which are served up by the API to be supplementary to the actual WebAPI methods.

The static files are served up just fine if you go to them directly, however if I try and ajax them in on another domain I get CORS issues.

The actual file in question is a static .html file.

I really don't want to create a wrapper controller to serve up static files as it opens a bunch of security concerns if I do it dynamically.

I am currently doing CORS with a custom DelegatingHandler (not the WebAPI2 builtin way) but this handler is not getting called for static files.

How can I intercept static file requests in WebAPI and apply the relevent CORS headers where applicable?

来源:https://stackoverflow.com/questions/24131711/webapi-cors-and-static-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!