.Net MVC操作webconfig

 因为项目需要,又捡起了.net.

因为修改System.Web.Configuration.WebConfigurationManager.AppSettings.Set("name","name1"),没有写权限。

var config = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(null); //配置文件在C盘.netframework.... 不推荐使用

 

自己新建了web.config

var config = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/config");

在config路径下回自动查找到Web.config

config.AppSettings.Settings.Add("name","name1");
config.Save();

 

 

现在网上的.net资料太少了....

 

posted on 2017-06-16 13:49  ...在路上...  阅读(167)  评论(0)    收藏  举报