我用自动生成软件生成了个三层,在web中添加页面
protected void Page_Load(object sender, EventArgs e)
{
String PassWordKey = "hgfedcba"; //获取用户的ip,password, url
String IP = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
String Url = "http://www.baidu.com/763OSHN400294JD0";
String Password = Request["pwd"] == null ? "" : Request.QueryString["pwd"].ToString(); xmlOperater myXml = new xmlOperater();
myXml.Read();
string xmlIP = myXml.Ip;
string xmlURL = myXml.Url;
if (IP == Convert.ToString(xmlIP) && Url == Convert.ToString(xmlURL) && Password == PassWordKey)
{
MSM_ErrorMessage opsd = new MSM_ErrorMessage();
BLL.MSM_ErrorMessage odsd = new Maticsoft.BLL.MSM_ErrorMessage();
opsd.cIp = IP;
opsd.cMessage = "";
opsd.cUrl = Url;
opsd.dCreateTime = DateTime.Now;
odsd.Add(opsd);
//判断ip是否已经插入
string str = ConfigurationManager.AppSettings["ConnectionString"];
SqlConnection con = new SqlConnection(str);
con.Open();
string strsql = "select from MSM_ErrorMessage where cIp";
if (strsql != null)
{
Response.Write("语句插入成功"); }
else
{
Response.Write("语句未插入");
} }
}
//页面异常处理
public void Page_Error(object sender, EventArgs e)
{
Exception error = Server.GetLastError().GetBaseException();
//在事件日志中记录异常
if (!EventLog.SourceExists("ApplicationException"))
{
EventLog.CreateEventSource("ApplicationException", "Application");
} EventLog eventLog = new EventLog();
eventLog.Log = "Application";
eventLog.Source = "ApplicationException";
eventLog.WriteEntry(error.ToString(), EventLogEntryType.Error); //发送Email给开发人员
//MailMessage email = new MailMessage("[email protected]",
//"[email protected]");
//email.Body = error.ToString();
//email.Subject = "An error occurred in the Application";
//SmtpClient smtpClient = new SmtpClient("192.168.1.12", 25);
//smtpClient.Send(email);
//Response.Redirect("Message.aspx");
} 为什么这里面的if不执行,而且设置断点也不是一步一步的执行?直接进入了空白页面
protected void Page_Load(object sender, EventArgs e)
{
String PassWordKey = "hgfedcba"; //获取用户的ip,password, url
String IP = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
String Url = "http://www.baidu.com/763OSHN400294JD0";
String Password = Request["pwd"] == null ? "" : Request.QueryString["pwd"].ToString(); xmlOperater myXml = new xmlOperater();
myXml.Read();
string xmlIP = myXml.Ip;
string xmlURL = myXml.Url;
if (IP == Convert.ToString(xmlIP) && Url == Convert.ToString(xmlURL) && Password == PassWordKey)
{
MSM_ErrorMessage opsd = new MSM_ErrorMessage();
BLL.MSM_ErrorMessage odsd = new Maticsoft.BLL.MSM_ErrorMessage();
opsd.cIp = IP;
opsd.cMessage = "";
opsd.cUrl = Url;
opsd.dCreateTime = DateTime.Now;
odsd.Add(opsd);
//判断ip是否已经插入
string str = ConfigurationManager.AppSettings["ConnectionString"];
SqlConnection con = new SqlConnection(str);
con.Open();
string strsql = "select from MSM_ErrorMessage where cIp";
if (strsql != null)
{
Response.Write("语句插入成功"); }
else
{
Response.Write("语句未插入");
} }
}
//页面异常处理
public void Page_Error(object sender, EventArgs e)
{
Exception error = Server.GetLastError().GetBaseException();
//在事件日志中记录异常
if (!EventLog.SourceExists("ApplicationException"))
{
EventLog.CreateEventSource("ApplicationException", "Application");
} EventLog eventLog = new EventLog();
eventLog.Log = "Application";
eventLog.Source = "ApplicationException";
eventLog.WriteEntry(error.ToString(), EventLogEntryType.Error); //发送Email给开发人员
//MailMessage email = new MailMessage("[email protected]",
//"[email protected]");
//email.Body = error.ToString();
//email.Subject = "An error occurred in the Application";
//SmtpClient smtpClient = new SmtpClient("192.168.1.12", 25);
//smtpClient.Send(email);
//Response.Redirect("Message.aspx");
} 为什么这里面的if不执行,而且设置断点也不是一步一步的执行?直接进入了空白页面
清理,重生生成,在调试试试
[/Quote
重新了好几次了,设置断点都不行,用自动生成软件生成的添加了个页面,就成这样了
{
//logic code
}
if(!IsPostoBack)
{
你的代码
}
然后把所有代码放到if(!IsPostoBack)
{}
{}
不然会出错的
String IP = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
String Url = "http://www.baidu.com/763OSHN400294JD0";
String Password = Request["pwd"] == null ? "" : Request.QueryString["pwd"].ToString(); xmlOperater myXml = new xmlOperater();
myXml.Read();
string xmlIP = myXml.Ip;
string xmlURL = myXml.Url;
if (IP == Convert.ToString(xmlIP) && Url == Convert.ToString(xmlURL) && Password == PassWordKey)
{
MSM_ErrorMessage opsd = new MSM_ErrorMessage();
BLL.MSM_ErrorMessage odsd = new Maticsoft.BLL.MSM_ErrorMessage();
opsd.cIp = IP;
opsd.cMessage = "";
opsd.cUrl = Url;
opsd.dCreateTime = DateTime.Now;
odsd.Add(opsd);
//判断ip是否已经插入
string str = ConfigurationManager.AppSettings["ConnectionString"];
SqlConnection con = new SqlConnection(str);
con.Open();
string strsql = "select from MSM_ErrorMessage where cIp";
if (strsql != null)
{
Response.Write("语句插入成功"); }
else
{
Response.Write("语句未插入");
} }
把这些写在方法列,在load里面调用,再调试吧。这样很难看清楚的!!
{//断点放在这里
断点放在事件下一行,如果没停,说明根本没有执行这个页面
那是不是你的启动页没设置呢?