标签:set com headers htm .net 其他 tom option cookie
比如 http://www.test.com 和 http://m.test.com
简单粗暴的方法 Web.Config
<system.web>
<!--其他配置 省略……-->
<httpCookies domain="test.com" /><!--同一顶级域名-->
</system.web>
<handlers>
<!--其他配置 省略……-->
<!--<remove name="OPTIONSVerbHandler" />--><!--这里一定得要注释掉OPTIONSVerbHandler。意思允许支持 OPTIONS -->
</handlers>
<httpProtocol>
<!--其他配置 省略……-->
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" /><!-- * 允许所有 或者 http://www.test.com 允许指定的地址-->
<add name="Access-Control-Allow-Credentials" value="true" /><!--允许携带Cookie-->
<add name="Access-Control-Allow-Methods" value="GET, HEAD, OPTIONS, POST, PUT" />
<add name="Access-Control-Allow-Headers" value="cache-control,content-type,if-modified-since,origin,x-requested-with,content-language" /><!--header支持的都填入,不够的继续添加-->
</customHeaders>
</httpProtocol>
//原生请求方式: var xhr = new XMLHttpRequest(); xhr.withCredentials = true; //JQuery 请求方式 $.ajaxSetup({crossDomain: true, xhrFields: {withCredentials: true}});
Asp.Net 跨域,Asp.Net MVC 跨域,Session共享
标签:set com headers htm .net 其他 tom option cookie
原文地址:https://www.cnblogs.com/smartstar/p/9771542.html