public class User
{
public class Model
{
public string UID { get; set; }
public string UserName { get; set; }
public string PassWord { get; set; }
public string UserIp { get; set; }
public int IsOnLine { get; set; }
public DateTime OnLineTime { get; set; }
public DateTime OffLineTime { get; set; }
public int UserSendPort { get; set; }
public int UserListenPort { get; set; }
}
public static class Service
{
private static string conn = System.Configuration.ConfigurationSettings.AppSettings["AccessConnStr"].ToString() + System.Web.HttpContext.Current.Server.MapPath(System.Configuration.ConfigurationSettings.AppSettings["DbPath"].ToString());
public static Model CurrentUser { get; set; }
}
}User.Model UserSelf = new User.Model();
UserSelf.UserName = UserName;
UserSelf.PassWord = PassWord;
User.Service.CurrentUser = UserSelf;//“Service”类型初始值设定项引发异常这个怎么解决?
{
public class Model
{
public string UID { get; set; }
public string UserName { get; set; }
public string PassWord { get; set; }
public string UserIp { get; set; }
public int IsOnLine { get; set; }
public DateTime OnLineTime { get; set; }
public DateTime OffLineTime { get; set; }
public int UserSendPort { get; set; }
public int UserListenPort { get; set; }
}
public static class Service
{
private static string conn = System.Configuration.ConfigurationSettings.AppSettings["AccessConnStr"].ToString() + System.Web.HttpContext.Current.Server.MapPath(System.Configuration.ConfigurationSettings.AppSettings["DbPath"].ToString());
public static Model CurrentUser { get; set; }
}
}User.Model UserSelf = new User.Model();
UserSelf.UserName = UserName;
UserSelf.PassWord = PassWord;
User.Service.CurrentUser = UserSelf;//“Service”类型初始值设定项引发异常这个怎么解决?
解决方案 »
- foreach怎么得到括号里面的值(要在括号外面用!)
- dataset里添加了一个table 怎么填充这个table
- 在第一次打开页面时,会显示为很小的图,刷新一下后就正常了。这是怎么回事? [Web 开
- 求一个论坛发布信息的控件
- 关于.net文件二进制上传
- MessageQueue在机器重启后..消息就没有拉?
- 请问,怎么解决这个错误???
- gridview 嵌套datalist的问题
- 紧急:asp.net同一页面在两个终端同时发送数据时,有一个数据没了
- SqlDataAdapter 如何更新,添加数据? C#
- ASP:fileupload控件與image控件同步顯示圖片問題
- DIV如何显示在active上方
比如:
public static Model CurrentUser { get { return 变量名; } set { 变量名 = value; }}
另外百度搜下:http://www.baidu.com/s?wd=%C0%E0%D0%CD%B3%F5%CA%BC%D6%B5%C9%E8%B6%A8%CF%EE%D2%FD%B7%A2%D2%EC%B3%A3&rsv_bp=0&n=2&inputT=570
找到了看懂了就不来csdn了
User.Model UserSelf = new User.Model();
UserSelf.UserName = UserName;
UserSelf.PassWord = PassWord;
User.Service.CurrentUser = UserSelf;//“Service”类型初始值设定项引发异常
private void BtnLogin_Click(object sender, EventArgs e)
{
string UserName = this.textBoxUserName.Text.Trim();
if (UserName == "")
{
MessageBox.Show("请填写用户名", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
string PassWord = this.textBoxPassWrod.Text.Trim();
if (PassWord == "")
{
MessageBox.Show("请填写密码", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
string result = Util.CallWebPage("http://"+Util.Host + ":" + Util.HostPort + "/ImWeb/Login.ashx", "UserName=" + Regex.Escape(UserName) + "&PassWord=" +Regex.Escape(PassWord), Encoding.UTF8);
Users.Model UserSelf = new Users.Model();
LoginResult.Model LoginResultModel = Serializer.JsonToObject<LoginResult.Model>(result);
if (LoginResultModel.Result==1)
{
UserSelf.UserName = UserName;
UserSelf.PassWord = PassWord;
Users.Service.CurrentUser = UserSelf;
Thread Main = new Thread(new ThreadStart(LoginSuccess));
Main.Start();
this.Close();
}
else
{
MessageBox.Show(LoginResultModel.Content.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private static string conn = System.Configuration.ConfigurationSettings.AppSettings["AccessConnStr"].ToString() + System.Web.HttpContext.Current.Server.MapPath(System.Configuration.ConfigurationSettings.AppSettings["DbPath"].ToString());//这句先换成下面这样调试,若没有错误,则是配置不正确或读取了web.config中不存在的节点
private static string conn = "";
最可能原因是你读取了web.config中不存在的值,请仔细检查大小写:),要完全和web.config AppSettings定义的键完全匹配。