如何将实体/参数添加到我的asp.net mvc应用程序中。我想允许cors通过asp.net webservice将ajax请求发送到数据库中。有没有人有解决此问题的经验?
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Headers" value="accept, content-type" />
<add name="Access-Control-Allow-Origin" value="http://localhost/QvAJAXZfc/opendoc.htm?document=test.qvw&lang=en-US&host=QVS%40servb"/>
<add name="Access-Control-Allow-Methods" value="POST, GET, OPTIONS" />
</customHeaders>
它向我显示一个错误,在我要访问的值的lang和host部分下划线。
亲切的问候
答案 0 :(得分:0)
确保将它们添加到正确的部分。将整个URL更改为仅localhost,它将起作用
<configuration>
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Headers" value="accept, content-type" />
<add name="Access-Control-Allow-Origin" value="http://localhost"/>
<add name="Access-Control-Allow-Methods" value="POST, GET, OPTIONS" />
</customHeaders>
</httpProtocol>
</system.webServer>
</configuration>