wwwrootフォルダにあり、ネットワーク内でローカルアクセス可能なMVC Web API(IISでホストされています)を持っています。http://mylocalapi:133/api/Values/Get
と私は結果を得る。ネットワーク外部の外部サイトから内部MVC Web APIを許可する方法
私はhttp://example.org
という外部サイトを持っていますが、同じhttp://mylocalapi:133/api/Values/Get
を実行したいと思います。
どちらも外部に面するサイトだけでなく、内部APIサイトは、同じサーバー上でホストされている(それは例えば、外部ネットワークのサードパーティベンダー異なる場合があります)私がで設定CORSを持って
このように私のAPI:
XMLHttpRequest cannot load http://mylocalapi:133. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://example.org' is therefore not allowed access.
[EnableCors(origins: "http://example.org", headers: "*", methods: "*")]
は、しかし、私は次のエラーを取得しておきます私がいることを、私がしようとしないとき
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<httpRedirect enabled="true" destination="http://mylocalapi:133" exactDestination="true" />
</system.webServer>
</configuration>
:
だから、それを回避、私は私の外部のサイトに仮想ディレクトリ(APICALLS
)を作成し、ローカルIISサイトを指しますweb.configファイルを作成しましたこのようにAPIにアクセス:http://example.org/APICALLS/api/Values/Get
が、私は次のエラーを取得する:
XMLHttpRequest cannot load http://mylocalapi:133. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://example.org' is therefore not allowed access.
私が間違っているのは何とどのように私はこの問題を解決することができます。
外部サイトからローカルホストにWebリクエストを送信しようとしましたが、間違っていますか?もしそうなら、あなたはできません。 – ibubi
@ibubi仮想ディレクトリでさえ? – Si8