IIS上发布了项目 本地浏览时点击了按钮没有触发事件
环境是这样的:VS2010,SQLSERVER2008,IIS5.1,XP 2002 SP3系统IIS上发布项目之后在本地测试,点击login页面上的登录时直接就进去main页面了,就算什么都不输入也可以进,感觉没有触发按钮点击的事件,但是没触发是怎么进到main页面的呢??我故意输入错误的账号密码或者什么都没输入也一样能进main页面,代码根本就不应该运行到那里去啊。。。
但是在VS里运行的时候一切正常。。。。
求大神指教。。。。 --------------------编程问答-------------------- 在服务器上的VS里设置断点跟一下。 --------------------编程问答-------------------- 额。。。我在VS里设置了的。。。没反应。。。 --------------------编程问答-------------------- 把代码发上来看下,应该是你的代码逻辑写的有问题 --------------------编程问答-------------------- protected void Button1_Click1(object sender, EventArgs e)
{
string utname,upwd;
utname = TextBox1.Text;
upwd = TextBox2.Text;
Gy gy = new Gy();
if (gy.Db_users(utname , upwd))
{
HttpCookie cookie = new HttpCookie("users");
// HttpCookie cookie2 = new HttpCookie("upwd");
cookie.Values.Add("utname",utname);
// cookie.Values.Add("upwd",upwd);
// string s = cookie.Values[0];
// Response.Write("<script language='javascript'>alert('"+ s +"');</script>");
Response.Cookies.Add(cookie);
Response.Redirect("main.aspx");
}
else {
Response.Write("<script language='javascript'>alert('账号或密码错误!');window.location.href='login.aspx';</script>");
//Response.Redirect("login.aspx");
}
}
class DbHelper
{
public static string constr = "Data Source=2011-20121111HE;Initial Catalog=Htgl;Integrated Security=True;" +
"uid=cd0320;pwd=ting0320cd";
public static SqlConnection con = new SqlConnection(constr);
}
public class GY{
public bool Db_users(string utname,string pwd){
string sql = "select * from t_user where utname='"+utname+"' and upwd='"+pwd+"'";
try
{
DbHelper.con.Open();
SqlCommand cmd = new SqlCommand(sql, DbHelper.con);
SqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
}
else
{
dr.Close();
DbHelper.con.Close();
return false;
}
dr.Close();
}
catch (Exception e)
{
string err = e.Message.ToString();
//Response.Redirect("Exceptions.aspx");
}
finally {
DbHelper.con.Close();
}
return true;
}
protected void Button1_Click1(object sender, EventArgs e)
{
string utname,upwd;
utname = TextBox1.Text;
upwd = TextBox2.Text;
Gy gy = new Gy();
if (gy.Db_users(utname , upwd))
{
HttpCookie cookie = new HttpCookie("users");
// HttpCookie cookie2 = new HttpCookie("upwd");
cookie.Values.Add("utname",utname);
// cookie.Values.Add("upwd",upwd);
// string s = cookie.Values[0];
// Response.Write("<script language='javascript'>alert('"+ s +"');</script>");
Response.Cookies.Add(cookie);
Response.Redirect("main.aspx");
}
else {
Response.Write("<script language='javascript'>alert('账号或密码错误!');window.location.href='login.aspx';</script>");
//Response.Redirect("login.aspx");
}
} --------------------编程问答-------------------- 奇怪这样看起来没有问题呀
--------------------编程问答-------------------- 代码应该没点问题。。我在VS里F5测试全部正常。。。 --------------------编程问答-------------------- 你写一个最简单的页面,里面只有一行代码就是输出一个字符串,看看.net环境没有问题吧,也就是说部署后iis能够正常解析.net的程序吧 --------------------编程问答-------------------- string utname,upwd;
utname = TextBox1.Text;
upwd = TextBox2.Text;
Response.Write("<script language='javascript'>alert('账号为:"+ utname +",密码为:"+upwd+"');</script>");
我这样写的
然后点击登录之后
真心郁闷的揪头发。。。 --------------------编程问答-------------------- 估计是iis配置有问题,重新全新配置一下吧 --------------------编程问答-------------------- IIS配置有问题么??额。。哪位大哥能发个好点的资料啊。。。我是新手。。。 --------------------编程问答-------------------- 你看下aspx页面的代码,是不是这里面写了跳转代码 --------------------编程问答-------------------- 看下给你的留言 --------------------编程问答-------------------- 绝对没有,我100%的肯定 --------------------编程问答-------------------- 感觉唯一出问题的恐怕是楼上那位说的。。。IIS配置有问题。。。 --------------------编程问答-------------------- 你把登录窗体 aspx 页面的代码发一下,看起来好像在iis中没有执行后台代码,是不是在前台也写了跳转代码 --------------------编程问答-------------------- 没写。。我能肯定
<body background="img/login.jpg" style="background-repeat:no-repeat">
<form id="form1" runat="server">
<div>
<br />
<br />
<table align="center"><tr><th class="style3"
style="font-family: 黑体; font-size: 30px">用户登陆<br />
<br />
</th></tr></table>
<table align="center">
<tr><td class="style1">账号:
</td><td class="style2">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</td></tr><tr><td></td></tr>
<tr><td class="style1">密码:</td><td class="style2">
<asp:TextBox ID="TextBox2" runat="server" TextMode="Password"></asp:TextBox>
</td></tr></table>
<table align="center">
<tr><td class="style1">
<br />
<asp:Button ID="Button1" runat="server" Text="登 陆" Height="21px" Width="70px"
onclick="Button1_Click1" />
</td></tr></table>
</div>
</form>
</body> --------------------编程问答-------------------- 属性配置里的那个 默认APS语言需要改成 C# 吗?系统是默认的VBScript
补充:.NET技术 , C#