コード例 #1
0
        //http://brockallen.com/2012/06/28/cors-support-in-webapi-mvc-and-iis-with-thinktecture-identitymodel/
        public static void RegisterCors(HttpConfiguration httpConfig)
        {
            WebApiCorsConfiguration corsConfig = new WebApiCorsConfiguration();
 
            // this adds the CorsMessageHandler to the HttpConfiguration’s
            // MessageHandlers collection
            corsConfig.RegisterGlobal(httpConfig);
       
            corsConfig.AllowAll();
        }
コード例 #2
0
ファイル: CorsConfig.cs プロジェクト: raymundinho/Esportsbuk
        public static void RegisterCors(HttpConfiguration httpConfig)
        {
            var corsConfig = new WebApiCorsConfiguration();
            corsConfig.RegisterGlobal(httpConfig);

            var allowedOrigins = WebConfigurationManager.AppSettings.Get("allowedOrigins");

            if (allowedOrigins == null) return;

            var allowedOriginList = allowedOrigins.Split(',');

            if (allowedOriginList.Contains("*"))
            {
                corsConfig.AllowAll();
                return;
            }

            corsConfig.ForOrigins(allowedOriginList).AllowAll();
        }
コード例 #3
0
ファイル: Global.asax.cs プロジェクト: qwert789/codegallery
 public static void RegisterCors(HttpConfiguration httpConfig)
 {
     var corsConfig = new WebApiCorsConfiguration();
     corsConfig.RegisterGlobal(httpConfig);
     corsConfig.AllowAll();
 }
コード例 #4
0
ファイル: CorsConfig.cs プロジェクト: Parsimotion/restsuite
 public static void RegisterCors(HttpConfiguration httpConfig)
 {
     var corsConfig = new WebApiCorsConfiguration {DefaultCacheDuration = 15000};
     corsConfig.AllowAll();
     corsConfig.RegisterGlobal(httpConfig);
 }