private void contextBeginRequest(object sender, EventArgs e)
        {
            HttpRequest request = HttpContext.Current.Request;
            string      origin  = request.Headers["Origin"];

            if (!(String.IsNullOrEmpty(origin)))
            {
                string myOrigin = (request.Url.Scheme
                                   + (Uri.SchemeDelimiter + request.Url.Host));
                if (!(request.Url.IsDefaultPort))
                {
                    myOrigin = (myOrigin
                                + (":" + Convert.ToString(request.Url.Port)));
                }
                if (origin != myOrigin)
                {
                    bool allowed = false;
                    SortedDictionary <string, string> config = ApplicationServices.Create().CorsConfiguration(request);
                    if (config != null)
                    {
                        foreach (KeyValuePair <string, string> kvp in config)
                        {
                            HttpContext.Current.Response.Headers[kvp.Key] = kvp.Value;
                            if ((kvp.Key == "Access-Control-Allow-Origin") && ((kvp.Value == "*") || kvp.Value.Split(',').Contains(origin)))
                            {
                                allowed = true;
                            }
                        }
                    }
                    if (!(allowed) || (request.HttpMethod == "OPTIONS"))
                    {
                        ((HttpApplication)(sender)).CompleteRequest();
                    }
                }
            }
        }
Esempio n. 2
0
 public static void RegisterFrameworkSettings(Page p)
 {
     if (!(p.ClientScript.IsStartupScriptRegistered(typeof(AquariumExtenderBase), "TargetFramework")))
     {
         p.ClientScript.RegisterStartupScript(typeof(AquariumExtenderBase), "TargetFramework", string.Format("var __targetFramework=\"4.6\",__tf=4.0,__servicePath=\"{0}\",__baseUrl=\"{1}\";", p.ResolveUrl(AquariumExtenderBase.DefaultServicePath), p.ResolveUrl("~")), true);
         p.ClientScript.RegisterStartupScript(typeof(AquariumExtenderBase), "TouchUI", (("var __settings=" + ApplicationServices.Create().UserSettings(p).ToString(Newtonsoft.Json.Formatting.None))
                                                                                        + ";"), true);
     }
 }
Esempio n. 3
0
 public static void RegisterFrameworkSettings(Page p)
 {
     if (!(p.ClientScript.IsStartupScriptRegistered(typeof(AquariumExtenderBase), "TargetFramework")))
     {
         string designerPort = ApplicationServices.DesignerPort;
         if (!(String.IsNullOrEmpty(designerPort)) && !(Controller.UserIsInRole(ApplicationServices.SiteContentDevelopers)))
         {
             designerPort = String.Empty;
         }
         p.ClientScript.RegisterStartupScript(typeof(AquariumExtenderBase), "TargetFramework", String.Format("var __targetFramework=\"4.6\",__tf=4.01,__servicePath=\"{0}\",__baseUrl=\"{1}\",__desig" +
                                                                                                             "nerPort=\"{2}\";", p.ResolveClientUrl(AquariumExtenderBase.DefaultServicePath), p.ResolveClientUrl("~"), designerPort), true);
         p.ClientScript.RegisterStartupScript(typeof(AquariumExtenderBase), "TouchUI", (("var __settings=" + ApplicationServices.Create().UserSettings(p).ToString(Newtonsoft.Json.Formatting.None))
                                                                                        + ";"), true);
     }
 }
 public static void RegisterFrameworkSettings(Page p)
 {
     if (!(p.ClientScript.IsStartupScriptRegistered(typeof(AquariumExtenderBase), "TargetFramework")))
     {
         string siteContent = String.Empty;
         p.ClientScript.RegisterStartupScript(typeof(AquariumExtenderBase), "TargetFramework", String.Format("var __targetFramework=\"4.5\",__tf=4.01;__servicePath=\"{0}\";__baseUrl=\"{1}\";", p.ResolveClientUrl(AquariumExtenderBase.DefaultServicePath), p.ResolveClientUrl("~")), true);
         p.ClientScript.RegisterStartupScript(typeof(AquariumExtenderBase), "TouchUI", String.Format(@"var __settings={{appInfo:""Prueba01|{0}"",mobileDisplayDensity:""Auto"",desktopDisplayDensity:""Condensed"",mapApiIdentifier:"""",labelsInList:""DisplayedBelow"",labelsInForm:""AlignedLeft"",initialListMode:""SeeAll"",buttonShapes:true,sidebar:""Landscape"",promoteActions:true,transitions:"""",theme:""Azure"",maxPivotRowCount: {1}{2}}};", BusinessRules.JavaScriptString(HttpContext.Current.User.Identity.Name), ApplicationServices.Create().MaxPivotRowCount, siteContent), true);
     }
 }