我可以在startup.cs中编写代码吗...调用我的DataAccess层和/或其他类的配置方法,在从DB或AppSettings从web.config文件读取配置后,将数据分配给我的静态类在启动期间阅读我的所有应用配置。我试图通过添加对我的类所在的库的引用来访问startup.cs中的静态类,但是我无法在我的asp.net MVC4应用程序中访问它。
namespace CAS.Common
{
public static class CommonConfiguration
{
public static string CDSRestClient { get; set; }
public static string ClientIdValue { get; set; }
public static string ClientSecretValue { get; set; }
}
}
Startup.cs中的代码
using System.Configuration;
using CAS.Common;
namespace myWebApp
{
public partial class Startup
{
public void Configuration(IAppBuilder app)
{
//This is the intended code, which I'm not able to do as I'm not able to access my static class here.
CommonConfiguration.CDSRestClient = ConfigurationSettings.AppSettings["CDSRestClient"].ToString().Trim();
CommonConfiguration.ClientIdValue = ConfigurationSettings.AppSettings["clientIdValue"].ToString().Trim();
CommonConfiguration.ClientSecretValue = ConfigurationSettings.AppSettings["clientSecretValue"].ToString().Trim();
}
}
}
谁能告诉我这里我做错了什么。