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 开发wap 网站,在ishtml32下,如果手机浏览器支持ishtml32,但是 SupportsCss=False 时,想加载css文件时,采用重写mobile:form的方法来实现
using System;
using System.Configuration;
using System.Web.UI.MobileControls;
using System.Web.UI.MobileControls.Adapters;
public class MyForm : Form
{ ......
1、DateTime 数字型
System.DateTime currentTime=new System.DateTime();
1.1 取当前年月日时分秒
currentTime=System.DateTime.Now;
1.2 取当前年
&nb ......
-----------------------------------------------------引言开始-----------------------------------------------------
事情的起因是站点出现未登陆的假象,点着点着就跳到登陆页或提示用户登陆。
因为很多页面都继承了一个PageBase类,这个类会判断用户是否登陆如果没有登陆就会 ......
asp.net 获取客户端计算机名
1. 在ASP.NET中专用属性:
获取服务器电脑名:Page.Server.ManchineName
获取用户信息:Page.User
获取客户端电脑名:Page.Request.UserHostName
获取客户端电脑IP:Page.Request.UserHostAddress
2. 在网络编程中的通用方法:
获取当前电脑名:static System.Net.Dns.GetHostNam ......
刚刚在headmenu控件里面写了一个导航条,用到了本地的图片,在控件中显示良好,可是放到母版式页后,发现导航条背景图片没了,于是仔细检查了下图片的url,我用的是绝对路径,难道放在主页上后,路径也改变了,上网查了下,还真是这个问题,图片在控件里面看不到没关系,关键是要在母版式页能看到就行,路径都要根据母版页的写. ......