本文整理汇总了C#中System.Web.HttpContext.GetSection方法的典型用法代码示例。如果您正苦于以下问题:C# HttpContext.GetSection方法的具体用法?C# HttpContext.GetSection怎么用?C# HttpContext.GetSection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.HttpContext
的用法示例。
在下文中一共展示了HttpContext.GetSection方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ServiceHostParser
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;
}
示例2: IsFiltered
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);
}
示例3: GetFromContext
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;
}
示例4: ProcessRequest
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));
}
示例5: OnEndRequest
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);
}
}
示例6: Load_DynamicDataLanguage_Page
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;
}
示例7: FindCommonPath
/// <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 [] { '/'} ) + "/";
}
示例8: GetMaxRequestLength
/// <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;
}
}
示例9: FindCommonPath
/// <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;
}