Example #1
0
        public static void RegisterCors(HttpConfiguration httpConfig)
        {
            WebApiCorsConfiguration corsConfig = new WebApiCorsConfiguration();

            corsConfig.RegisterGlobal(httpConfig);

            corsConfig
            .ForResources("Values1")
            .ForOrigins("http://localhost")
            .AllowMethods("GET", "POST");

            corsConfig
            .ForResources("Values2")
            .ForOrigins("http://localhost")
            .AllowMethods("GET", "POST")
            .AllowCookies()
            .AllowResponseHeaders("Foo");

            corsConfig
            .ForResources("Values3")
            .ForOrigins("http://localhost")
            .AllowMethods("GET", "POST", "PUT")
            .AllowRequestHeaders("Content-Type");

            corsConfig
            .ForResources("Values4")
            .ForOrigins("http://localhost")
            .AllowAllMethods()
            .AllowCookies()
            .AllowRequestHeaders("Content-Type", "Foo", "Authorization")
            .AllowResponseHeaders("Foo");
        }
    public static void RegisterCors(HttpConfiguration httpConfig)
    {
        var corsConfig = new WebApiCorsConfiguration();

        // this adds the CorsMessageHandler to the HttpConfiguration’s

        // MessageHandlers collection

        corsConfig.RegisterGlobal(httpConfig);

        // this allow all CORS requests to the Products controller

        // from the http://foo.com origin.

        corsConfig.ForResources("RestfulObjects").
        ForOrigins("http://localhost:49998",
                   "http://localhost:8080",
                   "http://nakedobjectstest.azurewebsites.net",
                   "http://nakedobjectstest2.azurewebsites.net",
                   "https://nakedobjectstest.azurewebsites.net",
                   "https://nakedobjectstest2.azurewebsites.net",
                   "http://localhost").
        AllowAll().
        AllowResponseHeaders("Warning", "Set-Cookie", "ETag").
        AllowCookies();
    }
Example #3
0
        public static void RegisterCors(HttpConfiguration httpConfig)
        {
            WebApiCorsConfiguration corsConfig = new WebApiCorsConfiguration();

            corsConfig.RegisterGlobal(httpConfig);
            corsConfig.ForAllResources().AllowAllOriginsAllMethodsAndAllRequestHeaders();
        }
Example #4
0
        public static void RegisterGlobal(HttpConfiguration httpConfig)
        {
            var corsConfig = new WebApiCorsConfiguration();

            corsConfig.RegisterGlobal(httpConfig);
            corsConfig.AllowAll();
        }
Example #5
0
        public static void RegisterCors(HttpConfiguration httpConfig)
        {
            WebApiCorsConfiguration corsConfig = new WebApiCorsConfiguration();

            corsConfig.RegisterGlobal(httpConfig);

            corsConfig.ForResources("Navigation")
            .ForOrigins("http://localhost:9240")
            .AllowAll();
        }
        //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();
        }
Example #7
0
        private static void ConfigureCors(HttpConfiguration config)
        {
            var corsConfig = new WebApiCorsConfiguration();

            config.MessageHandlers.Add(new CorsMessageHandler(corsConfig, config));

            corsConfig
            .ForAllOrigins()
            .AllowAllMethods()
            .AllowAllRequestHeaders();
        }
        public static void RegisterCors(HttpConfiguration httpConfig)
        {
            WebApiCorsConfiguration corsConfig = new WebApiCorsConfiguration();

            corsConfig.RegisterGlobal(httpConfig);

            corsConfig
            .ForResources("Employees")
            .ForOrigins("http://localhost:14126")
            .AllowRequestHeaders("Authorization")
            .AllowMethods("GET");
        }
        public static void RegisterCors(HttpConfiguration httpConfig)
        {
            WebApiCorsConfiguration corsConfig = new WebApiCorsConfiguration();

            // this adds the CorsMessageHandler to the HttpConfiguration's
            // MessageHandlers collection
            corsConfig.RegisterGlobal(httpConfig);

            // this allow all CORS requests to the Products controller
            // from the http://foo.com origin.
            corsConfig.ForAllOrigins().AllowAll();
        }
Example #10
0
        public static void RegisterCors(HttpConfiguration httpConfig)
        {
            WebApiCorsConfiguration corsConfig = new WebApiCorsConfiguration ();

            // this adds the CorsMessageHandler to the HttpConfiguration’s
            // MessageHandlers collection
            corsConfig.RegisterGlobal(httpConfig);

            // this allow all CORS requests to the Products controller
            // from the http://foo.com origin.

            //corsConfig.ForAllResources().AllowAllOriginsAllMethodsAndAllRequestHeaders();
            corsConfig.AllowAll();
            /*
            corsConfig
            .ForResources(“Products”)
            .ForOrigins(“http://foo.com”)
            .AllowAll();*/
        }
        //http://brockallen.com/2012/06/28/cors-support-in-webapi-mvc-and-iis-with-thinktecture-identitymodel/
        protected virtual void RegisterCors(HttpConfiguration configuration, string allowedOrigins)
        {
            configuration.MessageHandlers.Add(new R22CorsWebkitHackHandler());
            var corsConfig = new WebApiCorsConfiguration();

            if (allowedOrigins == null)
            {
                corsConfig
                .ForAllOrigins()
                .AllowAllMethods()
                .AllowCookies()
                .AllowRequestHeaders(_allowedRequestHeaders);
            }
            else
            {
                corsConfig
                .ForOrigins(allowedOrigins.Split(','))
                .AllowAllMethods()
                .AllowCookies()
                .AllowRequestHeaders(_allowedRequestHeaders);
            }

            corsConfig.RegisterGlobal(configuration);
        }