コード例 #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");
        }
コード例 #2
0
    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();
    }
コード例 #3
0
        public static void RegisterCors(HttpConfiguration httpConfig)
        {
            WebApiCorsConfiguration corsConfig = new WebApiCorsConfiguration();

            corsConfig.RegisterGlobal(httpConfig);

            corsConfig.ForResources("Navigation")
            .ForOrigins("http://localhost:9240")
            .AllowAll();
        }
コード例 #4
0
        public static void RegisterCors(HttpConfiguration httpConfig)
        {
            WebApiCorsConfiguration corsConfig = new WebApiCorsConfiguration();

            corsConfig.RegisterGlobal(httpConfig);

            corsConfig
            .ForResources("Employees")
            .ForOrigins("http://localhost:14126")
            .AllowRequestHeaders("Authorization")
            .AllowMethods("GET");
        }