扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:中国IT实验室 来源:中国IT实验室 2007年8月31日
关键字: 值 MaxRequest 读取
static public double getMaxlength()
...{
System.Web.Configuration.HttpRuntimeSection hrs = 
/**/////return hrs.MaxRequestLength * 1024;
return hrs.MaxRequestLength ;
}
static public string getMaxlengthByAppSetting()
...{
//先在Web.Config文件中增加一个key ****************************************//
// <appSettings>
// <add key="maxRequestLength" value="1550000"/>
//</appSettings>
//再来读取这个值,遗憾的是,这样只能写两遍,即
//<system.web>
//<httpRuntime maxRequestLength="1550000" executionTimeout="3600"/>
//</system.web>
//这两个值必须保持一致。
Configuration config = WebConfigurationManager.OpenWebConfiguration("~");
return config.AppSettings.Settings["maxRequestLength"].Value;

/**//* *********************以下为修改某个AppSettings的Key值。
////Configuration config = WebConfigurationManager.OpenWebConfiguration("~");
////if (config.AppSettings.Settings["MyAppKey"] == null)
//// config.AppSettings.Settings.Add("MyAppKey", "Hello!");
////else
//// config.AppSettings.Settings["MyAppKey"].Value = "Hello2!";
////config.Save();
*/
}如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。