问题标签 [webconfigurationmanager]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
875 浏览

asp.net - 如何在 Web 应用程序子文件夹中检索 web.config 设置

我的 Web 应用程序中有一个子文件夹。它不是一个单独的应用程序,只是一个子文件夹,但它有自己的 web.config。该子文件夹中有一个 aspx 页面,需要访问其自己文件夹中的 web.config 文件中的设置。

当我从该 aspx 页面上的静态初始化程序调用 ConfigurationManager.GetSection("settingname") 时,它返回 null。为什么会发生这种情况?可能是我的设置名称错误,或者正在访问应用程序根 web.config 而不是子文件夹的 web.config?

0 投票
1 回答
114 浏览

asp.net - 在线更新当前 web.config

我在我的 Web 应用程序上创建了一个屏幕,允许超级管理员更改 Web.Config 上的参数值。

问题

有一次我们使用连接到应用程序的用户必须刷新它的代码更改参数值!我想知道这是否是个好主意>

编码:

为什么应用程序是 KO 更改 web.config。

0 投票
0 回答
105 浏览

web-config - 遍历 web.config 中的“自定义”部分

我正在创建一个验证页面,以便当我的应用程序从 dev->qa->prod 移动时,我可以验证 web.config 中的所有设置是否已更改。

循环连接字符串和应用程序设置很容易,但我很难从“自定义”部分获取信息。特别是 elmah 数据。

我写了这个行得通,但这是一项非常糟糕的工作,我确信有一种更清洁的方法。

有什么建议么?

0 投票
0 回答
288 浏览

reflection - 使用 Activator.CreateInstance() 方法的替代方法是什么?

我正在动态创建记录器类型的对象,尝试使用反射的概念。我的代码如下。

我想放弃使用 Activator.CreateInstance() 方法。我的替代选择是什么?

0 投票
1 回答
1210 浏览

sharepoint - 如何在 SharePoint 中以编程方式将部分添加到 Web 配置

我有很多自定义条目要在 SharePoint 的 Web 配置中进行。有没有办法我们可以以编程方式做到这一点。比如我有这个要添加

我还有一个完整的新部分要添加,称为

我怎么能以编程方式做任何想法请

0 投票
0 回答
128 浏览

c# - Elmah 没有在 C# 中捕获 WebConfigurationManager.AppSettings[""].ToString() 异常

我有以下代码;

我发现尚未声明 App Setting 'FilePath'(不存在),并且"Object reference not set to an instance of an object"在这行代码中出现异常。

但是,我让 Elmah 在我的项目中工作,但它没有捕获并记录此异常,而是记录了所有其他异常。

我哪里出错了,为什么这个异常没有被捕获。我理解 Elmah 会捕获所有未处理的异常。

更新:

我在调用周围添加了一个 try catch,它确实捕获了异常。

有些我很困惑为什么 Elmah 没有记录和捕获异常。

0 投票
1 回答
197 浏览

c# - 更改 appSettings webconfig 上的值。仅适用于第二个页面加载

我正在运行以下代码。在我的 webconfig 中更改 appSetting。但是我必须做一个额外的页面加载来“创造魔法”。

第一个。页面加载。使用以前的设置。第二个页面加载。好的。

我把它放在里面Page_PreInit

0 投票
1 回答
311 浏览

c# - Saving changes to web.config using System.Configuration.ConfigurationSection

I have created a custom web config section that I can read and modify successfully at runtime. However, it does not physically change the web.config. If the site is restarted or the pool is recycled I lose my changes and it reverts to the original web.config settings.

I would like to be able to persist the changes to the web.config file and I have not been able to figure this out.

My web.config section looks like this:

Here is my configuration class

In my controller, I modify the settings with the posted form

In the config class save method, IsModified() returns true, now I just need to get those modifications to file.

0 投票
1 回答
181 浏览

c# - Exception with WebConfigurationManager.AppSettings.Get("urlAddress")

I am very new to working with XML. I've been weeding my way through debugging a project that was handed to me, but have run into quite a wall.

My code:

But the WebConfigurationManager.AppSettings.Get("urlAddress") is giving me the following Exception:

Invalid name character in 'eclRequest xmlns='''. The ' ' character, hexadecimal value 0x20, cannot be included in a name.

I was wondering what exactly this Get() statement is accessing, and what could be causing the Exception?

0 投票
1 回答
137 浏览

system.web - 无法在 VS 2012 中以编程方式访问 WebConfigurationManager

在我的 VS 2012 项目中,我引用了 System.Web。

如果我在 Object Brower 中浏览 System.Web,它包含 System.Web.Configuration.WebConfigurationManager;但在我的代码中,System.Web只显示我AspNetHostingPermission, AspNetHostingPermissionAtribute, AspNetHostingPermissionLevel...

在 VS2010 中我没有这个问题。

有什么建议么?