简体   繁体   English

调用读取Web.config的Web MVC DLL的C#控制台应用程序无法加载Web.config值

[英]C# Console application calling a Web MVC DLL that reads Web.config fails to load Web.config values

I have a console application that references an C# MVC web project DLL. 我有一个引用C#MVC Web项目DLL的控制台应用程序。 The console application calls into some of the functions exposed in the controller. 控制台应用程序调用控制器中公开的某些功能。 The controller then goes onto call other model functions. 然后,控制器继续调用其他模型功能。

Since the controller reads setting from its Web.config file (located in its project), when the console application calls into the controller functions, the settings that the controller reads is all null. 由于控制器从其Web.config文件(位于其项目中)读取设置,因此当控制台应用程序调用控制器功能时,控制器读取的设置都为空。

Is there a way around this other than my overriding all the controller APIs to also take in these settings as a parameter? 除了覆盖所有控制器API并将这些设置作为参数之外,还有其他方法吗?

您可以想到的选项:1.在App.config中具有相同的设置2.将Web.config中的设置移动到资源文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM