<configuration> <system.webServer> <modules> <add name="CultureAwareHttpModule" type="Web_SJWD.Lang.CultureAwareHttpModule" /> </modules> <validation validateIntegratedModeConfiguration="false" /> <!---加下面这段可以跨域---> <httpProtocol> <customHeaders> <remove name="X-Powered-By" /> <add name="Access-Control-Allow-Origin" value="*" /> <add name="Access-Control-Allow-Headers" value="*" /> <add name="Access-Control-Allow-Methods" value="GET, POST, PUT, DELETE" /> </customHeaders> </httpProtocol> </system.webServer> </configuration>
一直提示不能跨域,在web.config里加入上面这段后,就可以允许跨域访问了。