我做的asp.net在开发的机器上正常,部署到另外一台机器上出现“未将对象引用设置到对象的实例”。具体是在登陆页面,输入用户名,密码,提交之后出现的,是什么问题呢?在出问题的机器上(win xp)只装了IIS5,.net framework 1.1;数据库是mysql 5.0。
已经设置了虚拟目录,并且设置成了应用程序。
已经设置了虚拟目录,并且设置成了应用程序。
解决方案 »
- WIN7中发布asp.net程序的问题
- 求一个MVC 的 MessageBox
- 判断控件是否获得焦点
- js 问题
- 很纳闷,说说ajax,atlas的区别
- 如何将 webpart 外观设置为圆角框?
- dataset中两个datatable怎么绑定到gridview中
- 求助,纠结了很久的登录问题
- 服务器控件 ComponentOne Studio for ASP.NET Q4 2004 和 Infragistics NetAdvantage ASP NET 2004 Vol 3的免费下载地址。
- windows.net什么时候出来?
- asp.net中关于无限级下拉菜单的实现
- Datalist可不可以这种样式?
===================================Server Error in '/cmesm/admin' Application.
--------------------------------------------------------------------------------Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]
admin.login.submit_ServerClick(Object sender, EventArgs e) in D:\Xu Yunzhe\My Design\CMESM\admin\login.aspx.cs:97
System.Web.UI.HtmlControls.HtmlInputButton.OnServerClick(EventArgs e) +108
System.Web.UI.HtmlControls.HtmlInputButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1277
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573
=============================================using System;
using System.Collections;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Data.Odbc;
using System.Drawing;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;namespace admin
{
/// <summary>
/// Summary description for login.
/// </summary>
public class login : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox id;
protected System.Web.UI.WebControls.TextBox pwd;
protected System.Web.UI.HtmlControls.HtmlInputButton submit;
protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator1;
protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator2;
protected System.Web.UI.WebControls.CheckBox PersistCookie;
protected System.Web.UI.WebControls.Label Message;
protected System.Web.UI.HtmlControls.HtmlForm FormAuthentication;
protected OdbcDataReader myReader;
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
} #region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.submit.ServerClick += new System.EventHandler(this.submit_ServerClick);
this.Load += new System.EventHandler(this.Page_Load); }
#endregion private void submit_ServerClick(object sender, System.EventArgs e)
{
string post = id.Text;
string ConnectionString = ConfigurationSettings.AppSettings["MySqlConnectionString"];
string CommandText = "select * from administrator where administrator='" + post + "'";
OdbcConnection myConnection = new OdbcConnection(ConnectionString);
OdbcCommand myCommand = new OdbcCommand(CommandText, myConnection);
try
{
// open connection to the database
myConnection.Open();
// run query
myReader = myCommand.ExecuteReader();
if (myReader.Read())
{
if ((id.Text == (string)myReader.GetValue(1)) && (pwd.Text == (string)myReader.GetValue(2)))
{
FormsAuthentication.RedirectFromLoginPage(id.Text, PersistCookie.Checked);
}
else
{
Message.Text = "Illegal username or password, please try again!";
}
}
}
catch (Exception ex)
{
// If an exception occurs, handle it.
throw (ex);
}
finally
{
// Whether we succeed or fail, close the database connection
myReader.Close();
myConnection.Close();
}
}
}
}