protected virtual void PerformCorsCheck()
        {
            var ctx = System.Web.HttpContext.Current;

            var httpRequest = new MvcRequest(new HttpRequestWrapper(ctx.Request));
            var accessRequest = new CorsAccessRequest(httpRequest);
            if (accessRequest.IsCors)
            {
                var accessResponse = MvcCorsConfiguration.Configuration.Engine.CheckAccess(accessRequest);
                if (accessResponse != null)
                {
                    var response = ctx.Response;
                    var httpResponse = new HttpContextResponse(new HttpResponseWrapper(response));
                    accessResponse.WriteResponse(httpResponse);
                }

                if (accessRequest.IsCorsPreflight)
                {
                    ctx.Response.StatusCode = 200;
                    ctx.Response.End();
                }
            }
        }
Exemplo n.º 2
0
        protected virtual void PerformCorsCheck()
        {
            var ctx = System.Web.HttpContext.Current;

            var httpRequest   = new MvcRequest(new HttpRequestWrapper(ctx.Request));
            var accessRequest = new CorsAccessRequest(httpRequest);

            if (accessRequest.IsCors)
            {
                var accessResponse = MvcCorsConfiguration.Configuration.Engine.CheckAccess(accessRequest);
                if (accessResponse != null)
                {
                    var response     = ctx.Response;
                    var httpResponse = new HttpContextResponse(new HttpResponseWrapper(response));
                    accessResponse.WriteResponse(httpResponse);
                }

                if (accessRequest.IsCorsPreflight)
                {
                    ctx.Response.StatusCode = 200;
                    ctx.Response.End();
                }
            }
        }