在Web.config中添加
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Methods" value="OPTIONS,POST,GET"/>
<add name="Access-Control-Allow-Headers" value="x-requested-with"/>
<add name="Access-Control-Allow-Origin" value="*" />//表示允许所有来源进行跨域访问
</customHeaders>
</httpProtocol>
</system.webServer>