Asp.Net WebApi 启用CORS跨域访问指定多个域名
1.后台action指定
EnableCors指定可访问的域名多个,使用逗号隔开
//支持客户端凭据提交,指定多个域名,使用逗号隔开
[EnableCors("http://localhost:51421,http://localhost:51422 ", "*", "*", SupportsCredentials = true)]
//支持客户端凭据提交
//[EnableCors("http://localhost:51421", "*", "*", SupportsCredentials = true)]
//[EnableCors("http://localhost:51421", "*", "*")]
// [EnableCors("*", "*", "*")]
public string GetOne()
{
//Microsoft.Owin.Cors.CorsOptions
return CookieHelper.GetString("username");
}
更多:
Asp.Net WebApi+Microsoft.AspNet.WebApi.Core 启用CORS跨域访问
Cors 跨域Access-Control-Allow-Origin
Ajax跨域请求中的Cookie问题(默认不带cookie等凭证)
Asp.Net WebApi 启用CORS跨域访问指定多个域名的更多相关文章
- Asp.Net WebApi+Microsoft.AspNet.WebApi.Core 启用CORS跨域访问
WebApi中启用CORS跨域访问 1.安装 Nugget包Microsoft.AspNet.WebApi.Cors This package contains the components to e ...
- spring boot / cloud (六) 开启CORS跨域访问
spring boot / cloud (六) 开启CORS跨域访问 前言 什么是CORS? Cross-origin resource sharing(跨域资源共享),是一个W3C标准,它允许你向一 ...
- 【转载】ASP.NET MVC设置允许跨域访问
默认情况下,浏览器端发送Ajax请求一般被禁止跨域访问,如A域名网站访问B域名网站的请求会被终止,在ASP.NET MVC项目中,我们可以配置相应的设置项,允许网站的接口跨域访问,主要需要设置Acce ...
- SpringBoot学习(3)-SpringBoot添加支持CORS跨域访问
SpringBoot学习(3)-SpringBoot添加支持CORS跨域访问 https://blog.csdn.net/yft_android/article/details/80307672
- Spring Boot 2中对于CORS跨域访问的快速支持
原文:https://www.jianshu.com/p/840b4f83c3b5 目前的程序开发,大部分都采用前后台分离.这样一来,就都会碰到跨域资源共享CORS的问题.Spring Boot 2 ...
- Springboot CORS跨域访问
Springboot CORS跨域访问 什么是跨域 浏览器的同源策略限制: 它是浏览器最核心也最基本的安全功能,如果缺少了同源策略,则浏览器的正常功能可能都会受到影响.可以说Web是构建在同源策略基础 ...
- 彻底解决Asp.netCore WebApi 3.1 跨域时的预检查204 options重复请求的问题
Asp.netCore WebApi 3.1 跨域的预检查options问题 1:我们直接使用core跨域的中间件 ,注入跨域服务, services.AddCors(options => { ...
- Asp.net Vnext api CORS( 跨域)
概述 跨域资源共享(CORS )是一种网络浏览器的技术规范,它为Web服务器定义了一种方式,允许网页从不同的域访问其资源.而这种访问是被同源策略所禁止的.CORS系统定义了一种浏览器和服务器交互的方式 ...
- ASP.net Web API允许跨域访问解决办法
来源 http://blog.csdn.net/wxg_kingwolfmsncn/article/details/48545099 遇到此跨域访问问题,解决办法如下: 方法一: 1. 在we ...
随机推荐
- linux c数据库备份第二版
#想知道更多请查看第一版"linux c数据库备份第一版" #include<sys/types.h> #include<sys/wait.h> #incl ...
- 初窥struts2(二)OGNL表达式
Struts2总结 Struts2完整的处理流程: 1 客户端发送请求,交给struts2控制器(StrutsPrepareAndExecuteFilter). 2 Filter控制器进行请求过滤 ...
- OSSEC集合
http://dcid.me/blog/2010/01/using-ossec-for-the-forensic-analysis-of-log-files/
- poj Pie
http://poj.org/problem?id=3122 #include<cstdio> #include<cstring> #include<cmath> ...
- 自定义xamarin.forms Entry 背景色以及边框
创建 一个Xamarin.Forms自定义控件. 自定义Entry控件可以通过继承来创建Entry控制,显示在下面的代码示例: public class MyEntry : Entry { ...
- Ultra-QuickSort(归并排序求逆序对数)
Time Limit: 7000MS Memory Limit: 65536K Total Submissions: 34283 Accepted: 12295 Description In ...
- 【数学】HDU 5753 Permutation Bo
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5753 题目大意: 两个序列h和c,h为1~n的乱序.h[0]=h[n+1]=0,[A]表示A为真则为 ...
- Balanced Binary Tree——LeetCode
Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary ...
- POJ 2718 穷举
题意:给定一组数字,如0, 1, 2, 4, 6, 7,用这些数字组成两个数,并使这两个数之差最小.求这个最小差.在这个例子上,就是204和176,差为28. 分析:首先可以想到,这两个数必定是用各一 ...
- webservice2-wsimport的使用
打开Eclipse,新建java项目,service_start cmd下运行wsimport(要配置jdk的环境变量,wsimport在JAVA_HOME/bin下) wsimport -d d:/ ...