webapi 跨域问题
程序员文章站
2022-06-24 13:55:46
参考:http://www.cnblogs.com/chenxizhang/p/3821703.html 给自己做个笔记 在web.config中添加这段代码 ......
参考:
给自己做个笔记
httpcontext.current.response.addheader("access-control-allow-credentials", "true"); httpcontext.current.response.addheader("access-control-allow-headers", "origin,x-requested-with,content-type"); httpcontext.current.response.addheader("access-control-allow-methods", "post,get,options"); httpcontext.current.response.addheader("access-control-allow-origin", "*");
在web.config中添加这段代码
<system.webserver> <httpprotocol> <customheaders> <add name="access-control-allow-origin" value="*" /> <add name="access-control-allow-headers" value="content-type" /> <add name="access-control-allow-methods" value="get, post, put, delete, options" /> </customheaders> </httpprotocol> <handlers> <remove name="extensionlessurlhandler-integrated-4.0" /> <remove name="optionsverbhandler" /> <remove name="traceverbhandler" /> <add name="extensionlessurlhandler-integrated-4.0" path="*." verb="*" type="system.web.handlers.transferrequesthandler" precondition="integratedmode,runtimeversionv4.0" /> </handlers> </system.webserver>
下一篇: CDR设置自定义文字为默认字体方法