在本地测试的时候没有问题,传到服务器上后执行就出现以下错误
不知道哪里出了问题,请高手指点[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 

解决方案 »

  1.   

    参考,贴代码上来,一般来说是程式问题出现500错误的原因是很多的,一般来说,如果程序出错,那么在浏览器内会返回给用户一个友好的错误提示,统一称之为服务器500错误。 解决的方法就是您必须在http中能够正确的获得错误信息,方法为:请打开浏览器,选择工具,internet选项,高级,在高级中的浏览项目里面有一个\"显示http友好错误提示\"的复选框,请取消该复选框,这样您可以获得正确的错误提示。 在获得正确的错误提示之后,您就可以根据该错误提示检查您具体的出错原因了 
      

  2.   

    可能是系统权限问题,给ASPNET账户和相关账户足够的权限试试。
      

  3.   

    打开 \"显示http友好错误提示\"的复选框 后 还是显示
    远程服务器返回错误: (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>");
            }
            
         }
      

  4.   

     获取数据的地址是否正确,是否能打开
    看看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{}
      

  5.   


    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);
    }
    试试
      

  6.   

    这段代码  我新建一个测试的页面 是可以正常运行的
    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();