ASP MVC - ConfigurationManager 找不到应用程序设置

发布于 2024-09-30 04:29:43 字数 251 浏览 1 评论 0原文

我正在使用 MS Test 来测试我的控制器的一项操作。此方法使用 ConfigurationManger 从 web.config 读取 appSettigns。由于某种原因,ConfigurationMangager 无法找到应用程序设置。在 NUNIT 中,我只需确保将 webconfig 文件的副本添加到测试项目中,以便在该上下文中运行时可用。但这对我不起作用。

有人可以告诉我在使用 MS 测试时我需要做什么来确保我的 web.config 处于需要的位置吗?

I am using MS Test to test one of my controller's actions. This method uses the ConfigurationManger to read appSettigns from the web.config. For some reason ConfigurationMangager is not able to find the appsettings. In NUNIT I would just make sure to add a copy of the webconfig file to the test project so that it is available when running in that context. However this is not working for me.

Can someone tell me what I need to do to make sure my web.config is where it needs to be when using MS test?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

长途伴 2024-10-07 04:29:43

尝试使用 app.config 而不是 web.config

Try using app.config instead of web.config

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文