易截截图软件、单文件、免安装、纯绿色、仅160KB

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(c#)数据类型格式转换大全

1、DateTime   数字型 
       System.DateTime currentTime=new System.DateTime(); 
  1.1 取当前年月日时分秒 
       currentTime=System.DateTime.Now; 
  1.2 取当前年 
   &nb ......

asp.net的sessionState节点

web.config关于sessionState节点的配置方案,sessionState有四种模式:off,inProc,StateServer,SqlServer。
1、off模式
从字面上就可以看出这个是关闭模式,如果当前页面不需要session的值,为了减少服务器资源,你可以去掉Session的开销。
<sessionState mode="off">或者页面上
<%@ Page EnableSessionState= ......

asp.net 获取客户端计算机名

asp.net 获取客户端计算机名
1. 在ASP.NET中专用属性:
获取服务器电脑名:Page.Server.ManchineName
获取用户信息:Page.User
获取客户端电脑名:Page.Request.UserHostName
获取客户端电脑IP:Page.Request.UserHostAddress
2. 在网络编程中的通用方法:
获取当前电脑名:static System.Net.Dns.GetHostNam ......

asp.net母版页使用控件时,控件中路径问题

刚刚在headmenu控件里面写了一个导航条,用到了本地的图片,在控件中显示良好,可是放到母版式页后,发现导航条背景图片没了,于是仔细检查了下图片的url,我用的是绝对路径,难道放在主页上后,路径也改变了,上网查了下,还真是这个问题,图片在控件里面看不到没关系,关键是要在母版式页能看到就行,路径都要根据母版页的写. ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号