asp.net – ConfigurationManager.GetSection返回null以显示正确
发布时间:2020-12-16 06:35:48 所属栏目:asp.Net 来源:网络整理
导读:这是关于web.config文件 这是ConfigSection configSectionssectionGroup name="HttpExceptionHandler" section name="errorLog" type="System.Configuration.SingleTagSectionHandler,System,Version=1.0.5000.0,Culture=neutral,PublicKeyToken=b77a5c56193
这是关于web.config文件
这是ConfigSection <configSections> <sectionGroup name="HttpExceptionHandler"> <section name="errorLog" type="System.Configuration.SingleTagSectionHandler,System,Version=1.0.5000.0,Culture=neutral,PublicKeyToken=b77a5c561934e089" /> <section name="errorMail" type="System.Configuration.SingleTagSectionHandler,PublicKeyToken=b77a5c561934e089" /> </sectionGroup> 这是SectionGroup: <HttpExceptionHandler> <errorLog type="MI.Generic.HttpExceptionHandler.SqlErrorLog,MI.Generic.HttpExceptionHandler" dataSource="opentraderdevdev" initialCatalog="MiTraderError" /> </HttpExceptionHandler> 这是代码: public class ErrorLogConfiguration : ConfigurationSection { public static ErrorLogConfiguration GetConfig() { return ConfigurationManager.GetSection("HttpExceptionHandlererrorLog") as ErrorLogConfiguration; } [ConfigurationProperty("initialCatalog",IsRequired = true)] public string InitialCatalog { get { return this["initialCatalog"] as string; } } [ConfigurationProperty("dataSource",IsRequired = true)] public string DataSource { get { return this["dataSource"] as string; } } } 返回始终为null.我已经没想完了.任何帮助赞赏. 解决方法
如何切换斜线方向:
return ConfigurationManager.GetSection("HttpExceptionHandler/errorLog") as ErrorLogConfiguration; 这是一个similar example from MSDN. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net – 从Web应用程序打印
- asp.net-mvc – 如何使用ASP.NET Web API的Ninject?
- asp.net – ‘检测到Autofac循环组件依赖性’错误
- asp.net – 在某些报告中,aspx Crystal Report Viewer可能会
- asp.net – Infragistics WebGrid与Telerik网格
- asp.net-mvc – 如何测试我的Web应用程序是否可以处理大量流
- asp.net – 没有角色的声明?
- WeihanLi.Npoi 近期更新
- CKEditor与CKFinder的配置
- asp.net – ProviderManifestToken’2008’与之前遇到的’2
推荐文章
站长推荐
- asp.net-mvc-4 – 如何在ASP.NET MVC 4中从数据库
- asp.net-mvc – 我应该在ASP.NET MVC项目中将类文
- 实现对Asp.NetMvc及Asp.NetCore的权限控制
- ASP.Net缓存疑难解答 – CacheDuration属性似乎没
- asp.net-mvc – ASP.NET MVC视图或URL应该有多少
- asp.net-mvc – 如何让ASP.NET MVC遵守我的custo
- 如何阻止.Net HttpWebRequest.GetResponse()引发
- asp.net – CollapsiblePanelExtender在初始页面
- 在asp.net中动态构建SiteMapPath
- asp.net-mvc-3 – 在动作过滤器中检查ModelState
热点阅读