在本地测试的时候没有问题,传到服务器上后执行就出现以下错误
不知道哪里出了问题,请高手指点[WebException: 远程服务器返回错误: (500) 内部服务器错误。]
System.Net.HttpWebRequest.GetResponse() +5314029
user_FindPwd_Renzheng.Button1_Click(Object sender, EventArgs e) +250
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565
不知道哪里出了问题,请高手指点[WebException: 远程服务器返回错误: (500) 内部服务器错误。]
System.Net.HttpWebRequest.GetResponse() +5314029
user_FindPwd_Renzheng.Button1_Click(Object sender, EventArgs e) +250
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565
远程服务器返回错误: (500) 内部服务器错误。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Net.WebException: 远程服务器返回错误: (500) 内部服务器错误。源错误: 执行当前 Web 请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。 堆栈跟踪:
[WebException: 远程服务器返回错误: (500) 内部服务器错误。]
System.Net.HttpWebRequest.GetResponse() +5314029
user_FindPwd_Renzheng.Button1_Click(Object sender, EventArgs e) +252
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565
我的代码是想通过一些判断,然后 传一个URL地址到服务器上 返回值 (短信接口用的)
发送成功,就把随机验证码update到数据库里,下面是一个button事件
执行以后 数据库里有插入数据 没有update验证码到code里 而且出现上面的错误
我把button的if条件都去掉后,可以执行,update验证码也可以到库里,不知道为什么 protected void Button1_Click(object sender, EventArgs e)
{
if (checkcode())
{
if (TelNum())
{
if (AddUser())
{
string str = CreateRandomCode(6);
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("http://211.136.153.14/smsjk/qxt232/mt.asp?Phone=" + txtTel + "&Content=棋乐休闲6位验证码:" + str + "");
request.Timeout = 150000;
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
{
//发送成功
SqlConnection conn = new SqlConnection(System.Web.Configuration.WebConfigurationManager.ConnectionStrings["WebUserDBConnectionString_4"].ToString());
SqlCommand comm = new SqlCommand();
comm.Connection = conn;
conn.Open();
comm.CommandText = "update [Account].[dbo].[QileAcc_user] set [Code]='" + str + "' where UID='"+txtUserID.Text+"' ";
comm.ExecuteNonQuery();
Response.Write("发送成功");
conn.Close();
}
}
}
else
{
Response.Write("<script>alert('手机号码已被认证,请确认后重新填写!')<script>");
}
}
else
{
Response.Write("<script>alert('验证码错误,请重新输入!')<script>");
}
}
看看HttpWebResponse.StatusCode
string url="http://www.hao123.com/";
string str="";
System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(url);
try{
System.Net.HttpWebResponse response=(System.Net.HttpWebResponse)request.GetResponse();
System.IO.StreamReader reader=new System.IO.StreamReader(response.GetResponseStream(),System.Text.Encoding.GetEncoding("gb2312"));
str=reader.ReadToEnd();
}
catch{}
var xmlHttp=false;
function createXMLHttpRequest(){
xmlHttp=false;
try{
xmlHttp = new XMLHttpRequest();
}
catch(trymicrosoft)
{
try{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch(othermicrosoft){
try{
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(failed){
return false;
}
}
}
if (!xmlHttp){
alert("错误!无法创建XMLHttpRequest对象!可能是您的浏览器不支持ajax."); }
}
function getInfo(url){
createXMLHttpRequest();
xmlHttp.open("get",url,true);
xmlHttp.onreadystatechange=function(){
if(xmlHttp.readyState==4&&xmlHttp.status==200){
alert(xmlHttp.responseText);
}
}
xmlHttp.send(null);
}
试试
string str = CreateRandomCode(6);
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("http://211.136.153.14/smsjk/qxt232/mt.asp?Phone=" + txtTel + "&Content=棋乐休闲6位验证码:" + str + "");
request.Timeout = 150000;
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
{
//发送成功
SqlConnection conn = new SqlConnection(System.Web.Configuration.WebConfigurationManager.ConnectionStrings["WebUserDBConnectionString_4"].ToString());
SqlCommand comm = new SqlCommand();
comm.Connection = conn;
conn.Open();
comm.CommandText = "update [Account].[dbo].[QileAcc_user] set [Code]='" + str + "' where UID='"+txtUserID.Text+"' ";
comm.ExecuteNonQuery();
Response.Write("发送成功");
conn.Close();