我们可以通过以下两种方式从web.config中检索配置节:
Configuration config = WebConfigurationManager.OpenWebConfiguration("/");
AuthenticationSection authSection = (AuthenticationSection)
config.GetSection(@"system.web/authentication");或
AuthenticationSection authSection = (AuthenticationSection)
WebConfigurationManager.GetSection(@"system.web/authentication");这两种方法有什么不同(除了在第一个示例中,我们通过代表配置文件的配置对象检索配置节)?
谢谢
发布于 2010-01-31 03:26:31
你没有使用两种不同的方法。如果你仔细观察,你的陈述几乎是相同的。唯一的小区别是,在第二个中,Open语句是隐含的,并通过对象自动执行。它们都以完全相同的方式做同样的事情。
https://stackoverflow.com/questions/2169098
复制相似问题