ASP.NET²Ù×÷web.config
ASP.NET¿ÉÒÔÀûÓÃWebConfigurationManagerºÍÖ±½ÓÀûÓÃXML·½Ê½²Ù×÷web.config,WebConfigurationManager±È½Ï¼òµ¥£¬µ«ÊÇÇå³ý×¢ÊÍ´úÂë¡£Á½Õß²Ù×÷·½Ê½¶¼ÐèÒªÓÐдȨÏÞ¡£
·½·¨Ò»£¬ÀûÓÃWebConfigurationManager£¬ÐèÒªÒýÓÃSystem.Web.Configuration.WebConfigurationManager£»
Ìí¼ÓÏ
Configuration config = WebConfigurationManager.OpenWebConfiguration(null);
AppSettingsSection app = config.AppSettings;
app.Settings.Add("key", "valueadd");
config.Save(ConfigurationSaveMode.Modified);
ÐÞ¸ÄÏ
Configuration config = WebConfigurationManager.OpenWebConfiguration(null);
AppSettingsSection app = config.AppSettings;
app.Settings["key"].Value = "valuemodify";
config.Save(ConfigurationSaveMode.Modified);
ɾ³ýÏ
Configuration config = WebConfigurationManager.OpenWebConfiguration(null);
AppSettingsSection app = config.AppSettings;
app.Settings.Remove("key");
config.Save(ConfigurationSaveMode.Modified);
ÐÞ¸ÄÁ¬½ÓÏ
Configuration config = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath);
ConnectionStringsSection conSection = (ConnectionStringsSection)config.GetSection("connectionStrings");
conSection.ConnectionStrings[Request["type"].ToString()].ConnectionString = Request["connstr"];
config.Save(ConfigurationSaveMode.Modified);
XmlDocument xmldoc = new XmlDocument();
string filename = Common.FilePath("../web.config");
&nbs
Ïà¹ØÎĵµ£º
asp.netÈçºÎ°ÑÎļþÉÏ´«µ½ÁíÍâһ̨·þÎñÆ÷?
ÎÒÓÃÓ³ÉäÍøÂçÅ̵ÄÐÎʽ,¿ÉÊdzÌÐòÎÞ·¨½«Îļþ±£´æµ½ÍøÂçÓ³ÉäÅÌÉÏ.
ÈçºÎ¹²ÏíÎļþ¼ÐµÄ»°,Îļþ¼Ð±ØÐëÓÐдÈëµÄȨÏÞ,¿ÉÊÇÕâÑùµÄ»°¾ÖÓòÍøÄÚËùÓеÄÈ˶¼¿ÉÒÔÉÏ´«µ½Õâ¸ö¹²ÏíĿ¼ÁË?
½¨Ò飺
Õâ¸öÎÒÕýºÃ×ö¹ýµÄ£¬ºÇºÇ£¬¸øÄã²Î¿¼
¼ÙÉèÓзþÎñÆ÷AÊÇweb·þÎñÆ÷£¬ÎļþҪͨ¹ýA·þÎñÆ÷ÉϵÄweb³ÌÐòÉÏ´«µ ......
-----------------------------------------------------ÒýÑÔ¿ªÊ¼-----------------------------------------------------
ÊÂÇéµÄÆðÒòÊÇÕ¾µã³öÏÖδµÇ½µÄ¼ÙÏ󣬵ã×ŵãמÍÌøµ½µÇ½ҳ»òÌáʾÓû§µÇ½¡£
ÒòΪºÜ¶àÒ³Ãæ¶¼¼Ì³ÐÁËÒ»¸öPageBaseÀ࣬Õâ¸öÀà»áÅжÏÓû§ÊÇ·ñµÇ½Èç¹ûûÓеǽ¾Í»á ......
@PageÖ¸ÁîλÓÚÿ¸öASP.NETÒ³ÃæµÄ¶¥²¿£¬¸æËßASP.NETÕâ¸ö¾ßÌåÒ³ÃæÊ¹ÓÃʲôÊôÐÔ£¬ÒÔ¼°¸ÃÒ³Ãæ¼Ì³ÐµÄÓû§¿Ø¼þ¡£ASP.NETÒ³Ãæ
@PageÖ¸ÁîÊôÐÔÓУºAspCompat¡¢Async¡¢AsyncTimeout¡¢AutoEventWireup¡¢Buffer¡¢
ClassName¡¢ClientIDMode¡¢CodeBehind¡¢
CodeFile¡¢CodeFileBaseClass¡¢CodePage¡¢CompilationMode ¡¢ContentType¡¢
......
Äú¿ÉÒÔͨ¹ýÒÔÏÂÉèÖÿØÖÆasp.net¶Ô·þÎñÆ÷ÄÚ´æµÄÕ¼Óᣲ¢ÄÜÉèÖÃaspnet½ø³Ì¶¨Ê±Öؽ¨£¨ÀàËÆIIS6ÖÐAppPoolÀïµÄ¶¨Ê±ÖØÆô£©£¬ÕâÑù¿ÉÒÔ±ÜÃâ·þÎñÆ÷³¤Ê±¼äÔËÐÐaspnetÕ¼ÓôóÁ¿¿ÕÏÐÄڴ棬ÓÐÀûÓÚÌá¸ßaspnetÔËÐÐЧÂÊ¡£
aspnetÅäÖÃÎļþλÖÃΪ
CWINDOWSMicrosoft.NETFrameworkv1.1.4322CONFIGmachine.config
ÓÃÎı¾±à¼Æ÷´ò¿ª¸ÃÎļþ£¬ÕÒµ ......