问题
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