本文整理汇总了C#中System.Web.HttpContext.GetConfig方法的典型用法代码示例。如果您正苦于以下问题:C# HttpContext.GetConfig方法的具体用法?C# HttpContext.GetConfig怎么用?C# HttpContext.GetConfig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.HttpContext
的用法示例。
在下文中一共展示了HttpContext.GetConfig方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetScriptLocation
internal static string GetScriptLocation(HttpContext context)
{
IDictionary dict = context.GetConfig("system.web/webControls")
as IDictionary;
string loc = null;
if(dict != null)
{
loc = dict["clientScriptsLocation"] as string;
}
if(loc == null)
{
throw new HttpException("Missing_clientScriptsLocation");
}
if(loc.IndexOf("{0}") > 0)
{
//FIXME: Version Number of the ASP.Net should come into play.
//Like if ASP 1.0 and 1.1 both are installed, the script
// locations are in /aspnet_client/system_web/1_0_3705_0/
// and /aspnet_client/system_web/1_1_4322/
// (these entries are from my machine
// So, first I should get this Version Info from somewhere
loc = String.Format(loc, "system_web");
}
return loc;
}
示例2: GetInstance
static public CompilationConfiguration GetInstance (HttpContext context)
{
CompilationConfiguration config;
if (context == null)
context = HttpContext.Context;
config = context.GetConfig ("system.web/compilation") as CompilationConfiguration;
if (config == null)
throw new Exception ("Configuration error.");
return config;
}
示例3: GetInstance
static public HttpRuntimeConfig GetInstance (HttpContext context)
{
HttpRuntimeConfig config;
if (context == null)
context = HttpContext.Context;
config = context.GetConfig ("system.web/httpRuntime") as HttpRuntimeConfig;
if (config == null)
throw new Exception ("Configuration error.");
return config;
}
示例4: GetInstance
static public CompilationConfiguration GetInstance (HttpContext context)
{
CompilationConfiguration config;
if (context == null)
context = HttpContext.Current;
if (context != null) {
config = context.GetConfig ("system.web/compilation") as CompilationConfiguration;
if (config == null)
throw new Exception ("Configuration error.");
} else {
// empty config (as used in unit tests)
config = new CompilationConfiguration (null);
}
return config;
}
示例5: RedirectCustomError
bool RedirectCustomError (HttpContext context)
{
if (!context.IsCustomErrorEnabled)
return false;
CustomErrorsConfig config = null;
try {
config = (CustomErrorsConfig) context.GetConfig ("system.web/customErrors");
} catch { }
if (config == null) {
if (context.ErrorPage != null)
return context.Response.RedirectCustomError (context.ErrorPage);
return false;
}
string redirect = config [context.Response.StatusCode];
if (redirect == null) {
redirect = context.ErrorPage;
if (redirect == null)
redirect = config.DefaultRedirect;
}
if (redirect == null)
return false;
return context.Response.RedirectCustomError (redirect);
}
示例6: 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.GetConfig(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 + version.Major.ToString() + "_" + version.Minor.ToString() + "/";
}