读web.config的代码。。。
急用,谢谢啊
代码如下:
using System;
using System.Collections.Generic;
using System.Text;
namespace TraveLine.SysHelpFrame
{
public class ApplacationHelper
{
private const string TRAVELINE_CONNECTIONSTRING = "TRAVELINE_CONNECTIONSTRING";
private const string TRAVELINE_CONNECTIONSTRING_DEFAULT = "Data Source=127.0.0.1;Initial Catalog=TraveLineDB;User ID=sa;password=";
private static string m_connectionString;
public static string TravelineConnectionStr
{
get
{
return m_connectionString;
}
set
{
m_connectionString = value;
}
}
protected static string ReadSetting(string key, string defaultValue)
{
try
{
string setting = System.Configuration.ConfigurationManager.AppSettings[key];
return (null == setting) ? defaultValue : setting;
}
catch
{
return defaultValue;
}
}
private static void ReadConveryanceConfiguration()
{
m_connectionString = ReadSetting(TRAVELINE_CONNECTIONSTRING, TRAVELINE_CONNECTIONSTRING_DEFAULT);
}
public static void OnAppStart(string appPath)
{
string m_appRoot = appPath;
// 读取配置节
ReadConveryanceConfiguration();
}
}
}