关于asp.net的配置文件
配置文件可用来存放一些多次用到的常量数据,如连接串:
<appSettings>
<add key="connStr1" value="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="/>
<add key="connStr2" value="App_Data\test.mdb"/>
</appSettings>
这个配置数据库连接串
使用示例:
public class DBConn
{
protected OleDbConnection _conn;
public DBConn(System.Web.UI.Page page)
{
string path = page.Server.MapPath(ConfigurationSettings.AppSettings["connStr2"]);
string connectString = ConfigurationSettings.AppSettings["connStr1"];
connectString += path;
_conn = new OleDbConnection(connectString);
_conn.Open();
}
........
<system.web>
<compilation debug="true" />
这个配置网站为DEBUG模式
<authentication mode="Windows"/>
这个配置为WINDWOS认证模式。
<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>
这个配置403,404出错时的传回页面
配置网站邮件服务器:
<mailSettings>
<smtp from="pclion2008@googlemail.com">
<network host="smpt.gmail.com" userName="" password=""/>
</smtp>
诸如此类。都是一些常量参数,因为多次用到这些参数,所以写在配置文件中用起来就方便多了。甚至某些临时数据也可以从程序中写入,让另一网页访问
相关文档:
(1)首先要对内容的特殊字符进行过虑:
C# 代码:
public string res(string partno)
{
partno = partno.Replace("&", "");
partno = partno.Replace("/", "");
partno = partno.Replace("&", "");
return partno;
}
(2)从数据库中获得要生成地图的内 ......
本人开发ASP.NET已有两年多了。谈起ASP.NET真是让我欢喜让我忧。昨天又出现了那个奇怪的问题,就是在页面完全写好后,重新生成时报:XXX(页面名)不包含(XXX)的定义。在CS文件下是可以用 this.xxx 写出来的,页面上也没问题。在解决方案中重新生成页又可以,重新生成网站就会报这个错误。将this.XXX ......
给出一个字符串,如“中国China我爱你I love you”,程序可以实现中英文的区别;
识别结果如下:共四个元素
中国
China
我爱你
I love you
string ptn = "[\u4e00-\u9fa5]+|[a-zA-Z\\s]+";
System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(ptn);
s ......
1 response.redirect 这个跳转页面的方法跳转的速度不快,因为它要走2个来回(2次postback),但他可以跳 转到任何页面,没有站点页面限制(即可以由雅虎跳到新浪),同时不能跳过登录保护。但速度慢是其最大缺陷!redirect跳转机制:首先是发送一个http请求到客户端,通知需要跳转到新页面,然后客户端在发送跳转 ......
Default.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" & ......