我能够在IIS上部署我的asp项目并显示首页,在那里我有一个登录页面,在输入它没有登录的凭据后,我使用了try和catch,并且在catch中它给了我一个错误,说明线程已中止,它在
page.redirect [ “master.apsx”,真]
所以我把它改成了
page.redirect [ “master.aspx”,假]
并没有给出错误,但它无法进一步登录,我猜它无法连接到数据库。所以任何帮助都会很明显。
由于
CODE:
protected void Page_Load(object sender, EventArgs e)
{
strconn = @"Data Source=.\SQLEXPRESS;AttachDbFilename=" + Server.MapPath("~/App_Data/Securityservice.mdf") + ";Integrated Security=True;User Instance=True";
Label1.Text = " conn string";
}
protected void Button2_Click(object sender, EventArgs e)
{
}
protected void btn_popup_quick_login_Click(object sender, EventArgs e)
{
try
{
if (txt_username.Text != null)
{
if (txt_password.Text != null)
{
DataTable dt = new DataTable();
conn = new SqlConnection(strconn);
conn.Open();
cmd = new SqlCommand("Select * From UserMaster Where Username=@username and Password=@password", conn);
cmd.Parameters.AddWithValue("@username", txt_username.Text);
cmd.Parameters.AddWithValue("@password", txt_password.Text);
da = new SqlDataAdapter(cmd);
da.Fill(dt);
{
if (dt.Rows.Count > 0)
{
userloginname = txt_username.Text;
userloginpassword = txt_password.Text;
Session["username"] = txt_username.Text;
MessageBox.Show("User Login Sucessfully", "Login", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
Response.Redirect("Marketing.aspx",false);
}
else
{
Label1.Text = "else part";
MessageBox.Show("Invalid User Name and Password", "Login", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
txt_username.Focus();
}
txt_username.Text = "";
txt_password.Text = "";
}
}
}
}
catch (Exception ex) { MessageBox.Show(ex.Message,"Error",MessageBoxButtons.OK,MessageBoxIcon.Error); }
conn.Close();
Label1.Text = "login";
}
答案 0 :(得分:0)
您应该检查web.config中的连接字符串,以确保在部署站点后它们仍然指向数据库的正确位置。
答案 1 :(得分:0)
我认为问题可能是Application_Start
方法
看看你是否写过一些东西。
在那里做一个断点,看看是否有任何错误。
或者您是否在代码中写了Response.End()
?
您需要提供更多细节