public ServiceHostParser (string file, string url, HttpContext context) { this.file = file; this.url = url; assemblies = new ArrayList (); assemblies.Add ("System.ServiceModel"); this.context = context; CompilationSection section = (CompilationSection) context.GetSection ("system.web/compilation"); language = section.DefaultLanguage; }
private static bool _IsFiltered(System.Exception e, System.Web.HttpContext context) { if (_config == null) { _config = (context.GetSection("elmah/errorFilter") as ErrorFilterConfiguration) ?? new ErrorFilterConfiguration(); } var context2 = new ErrorFilterModule.AssertionHelperContext((System.Exception)e, context); return(_config.Assertion.Test(context2)); }
private static bool IsFiltered(Exception e, HttpContext context) { if (_config == null) { _config = context.GetSection("elmah/errorFilter") as ErrorFilterConfiguration ?? new ErrorFilterConfiguration(); } var testContext = new ErrorFilterModule.AssertionHelperContext(e, context); return _config.Assertion.Test(testContext); }
internal static ControlsConfig GetFromContext(HttpContext context) { // VSWhidbey 372365: Use MobileControlsSection if it is being returned Object config = context.GetSection("system.web/mobileControls"); MobileControlsSection controlSection = config as MobileControlsSection; if (controlSection != null) { return controlSection.GetControlsConfig(); } return (ControlsConfig)config; }
public void ProcessRequest(HttpContext context) { var @params = context.Request.Params; var errorText = Decode(@params["error"]); var errorId = @params["errorId"]; var sourceId = @params["sourceId"]; var infoUrl = @params["infoUrl"]; var infoUrlPath = string.IsNullOrWhiteSpace(infoUrl) ? string.Empty : new Uri(infoUrl).AbsoluteUri; var section = context.GetSection("elmahr") as RootSection; var hasSection = section != null; if (!hasSection) return; var error = ( from _ in new[] { errorText } let hasSource = section.Applications.Any(a => a.SourceId == sourceId) let secret = hasSource ? section.Applications.Single(a => a.SourceId == sourceId).Secret : string.Empty let hasSecret = !string.IsNullOrWhiteSpace(secret) select hasSecret ? Crypto.DecryptStringAes(errorText, secret) : errorText) .FirstOrDefault(); var payload = Error.ProcessAndAppendError( sourceId, errorId, error, infoUrlPath, ex => { Hub.Log(string.Format("An error occurred in ElmahR: {0}", ex), Hub.Severity.Critical); Error.ProcessError( Error.ElmahRSourceId, ex, infoUrlPath, _ => { }, true); }, true); if (payload != null) Hub.Log(string.Format("Received error from {0}: {1}", payload.GetApplication().ApplicationName, payload.Message)); }
protected virtual void OnEndRequest(HttpContext context) { if (context.Response.StatusCode == 302 && context.Items.Contains("FormsAuthBypass") && (bool)context.Items["FormsAuthBypass"]) { context.Response.Clear(); //context.Response.Headers.Remove("Location"); //only works with IIS7 context.Response.StatusCode = 401; context.Response.StatusDescription = "Access Denied"; CustomErrorsSection customErrorsSection = (CustomErrorsSection)context.GetSection("system.web/customErrors"); string url = customErrorsSection.DefaultRedirect; // Get the collection foreach (CustomError e in customErrorsSection.Errors) { if (context.Response.StatusCode == e.StatusCode) url = e.Redirect ?? url; } context.Server.Transfer(url); } }
public static string Load_DynamicDataLanguage_Page(HttpContext Context, string SYSTEM) { string PageHTML = Context.Request["filename"].ToString(); LanguagesBO aLanguagesBO = new LanguagesBO(); ConfigsBO aConfigsBO = new ConfigsBO(); List<Configs> ListConfigsCMS = new List<Configs>(); List<string> ListCodeCMS = new List<string>(); ListConfigsCMS = aConfigsBO.Sel_ByAccessKey(key_DEF_LANG_CMS); for (int i = 0; i < ListConfigsCMS.Count; i++) { ListCodeCMS.Add(ListConfigsCMS[i].Value.ToString()); } string ListCodeTemptCMS = String.Join(",", ListCodeCMS); List<Configs> ListConfigsWEB = new List<Configs>(); List<string> ListCodeWEB = new List<string>(); ListConfigsWEB = aConfigsBO.Sel_ByAccessKey(key_DEF_LANG_WEB); for (int i = 0; i < ListConfigsCMS.Count; i++) { ListCodeWEB.Add(ListConfigsWEB[i].Value.ToString()); } string ListCodeTemptWEB = String.Join(",", ListCodeWEB); sys_NUM_LANG = aLanguagesBO.Sel().ToList().Count; if (SYSTEM == "CMS") { sys_DEF_LANG = int.Parse(ListCodeTemptCMS); } else if (SYSTEM == "WEB") { sys_DEF_LANG = int.Parse(ListCodeTemptWEB); } if (!string.IsNullOrEmpty(Context.Request.QueryString["IDLang"])) { sys_CUR_LANG = Convert.ToInt32(Context.Request.QueryString["IDLang"]); } else { if (Context.GetSection(key_CUR_LANG) != null) { sys_CUR_LANG = Convert.ToInt32(Context.GetSection(key_CUR_LANG).ToString()); } // Cuoi cung moi lay den ngon ngu mac dinh else { sys_CUR_LANG = int.Parse(ListCodeTemptCMS); } } string PhysicalPath = Context.Server.MapPath(@"\\Languages\\" + aLanguagesBO.Sel_ByID(sys_CUR_LANG).NameLang + "\\" + PageHTML + ".xml"); XmlDocument doc = new XmlDocument(); doc.Load(PhysicalPath); XmlElement element = doc.DocumentElement; XmlNodeList attr_coll = doc.SelectNodes("//item"); List<LanguagesItem> List_ItemLang = new List<LanguagesItem>(); LanguagesItem Item; foreach (XmlNode node in attr_coll) { Item = new LanguagesItem(); Item.Text = node.InnerText; Item.Key = node.Attributes["Index"].Value; List_ItemLang.Add(Item); } String jSonString = ""; InfoLang aInfoLang = new InfoLang(); aInfoLang.DATA_LANG = List_ItemLang; aInfoLang.sys_CUR_LANG = sys_CUR_LANG; aInfoLang.sys_DEF_LANG = sys_DEF_LANG; aInfoLang.sys_NUM_LANG = sys_NUM_LANG; _converter.DateTimeFormat = "dd/MM/yyyy"; jSonString = JsonConvert.SerializeObject(aInfoLang, _converter); CORE_Language.aInfoLang.DATA_LANG = List_ItemLang; // Chỗ chứa dữ liệu cho cách thức truy cập từ trang aspx return jSonString; }
public override object GetSection(string sectionName) { return(w.GetSection(sectionName)); }
/// <summary> /// Finds the path for client files used be server controls. /// </summary> /// <param name="context">The context from which to get the configuration.</param> /// <returns>The path name.</returns> private static string FindCommonPath(HttpContext context) { // Look at the current configuration for the path if (context != null) { NameValueCollection table = (NameValueCollection)context.GetSection (ConfigName); if (table != null) { string path = (string)table[CommonFilesKey]; if (path != null) { return CleanupPath(path); } } } // Return the default path with version number Assembly assembly = typeof(BaseRichControl).Assembly; Version version = assembly.GetName().Version; return DefaultCommonFilesRoot.TrimEnd ( new char [] { '/'} ) + "/"; }
/// <summary> /// Gets the maximum request length from the configuration settings. /// </summary> /// <param name="context">Http context.</param> /// <returns>The maximum request length (in kb).</returns> int GetMaxRequestLength(HttpContext context) { int DEFAULT_MAX = 4096; // Look up the config setting System.Web.Configuration.HttpRuntimeSection config = context.GetSection("system.web/httpRuntime") as System.Web.Configuration.HttpRuntimeSection; if (config == null) { return DEFAULT_MAX; // None found. Return the default setting. } else { return config.MaxRequestLength; } }
/// <summary> /// Finds the path for client files used be server controls. /// </summary> /// <param name="context">The context from which to get the configuration.</param> /// <returns>The path name.</returns> private static string FindCommonPath(HttpContext context) { // Look at the current configuration for the path if (context != null) { NameValueCollection table = (NameValueCollection)context.GetSection(ConfigName); if (table != null) { string path = (string)table[CommonFilesKey]; if (path != null) { return CleanupPath(path); } } } // Return the default path with version number Assembly assembly = typeof(BaseRichControl).Assembly; Version version = assembly.GetName().Version; // fix spacer.gif dvs: 2009-06-18 //return DefaultCommonFilesRoot + version.Major.ToString() + "_" + version.Minor.ToString() + "/"; return string.Empty; }
/// <summary> /// See <see cref="System.Web.HttpContext"/> for a description. /// </summary> public object GetSection(string sectionName) { return(_context.GetSection(sectionName)); }