locked
HTTP 408 - Request timed out RRS feed

  • Question

  • User-174306217 posted

    hi all, i have been developing an mobile to asp site app. All of a sudden i am getting http 408 request timed outerror after just a couple of seconds. This can happen and then i can try again and it'll work fine. Could anyone please offer suggestions to try. I am stumped.

     

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System;
    using System.Collections;
    using System.Configuration;
    using System.Data;
    using System.Data.SqlClient;
    using System.Linq;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Xml.Linq;
    
    public partial class login : System.Web.UI.Page
    {
            String username;
            String password;
            String phoneNumber;
            String deviceType;
            String dbPassword;
            SqlConnection cnn = null;
            SqlCommand cmd = null;
            string sql = null;
            SqlDataReader reader;
    
            System.Collections.Specialized.NameValueCollection nvc;
        protected void Page_Load(object sender, EventArgs e)
            {
            try{
                     Server.ScriptTimeout = 3000;
    
                    Response.Cache.SetCacheability(HttpCacheability.NoCache);
    
                    if (!string.IsNullOrEmpty(Page.Request.Headers["username"].ToString()))
                    {
                            username = Page.Request.Headers["username"].ToString();
                            //  username = nvc["username"];  
    
                    }
    
                    if (!string.IsNullOrEmpty(Page.Request.Headers["password"].ToString()))
                    {
                            //  Response.Write("here3 ");
                            password = Page.Request.Headers["password"].ToString();
                    }
    
                    if (!string.IsNullOrEmpty(Page.Request.Headers["phonenumber"].ToString()))
                    {
                            phoneNumber = Page.Request.Headers["phonenumber"].ToString();
                    }
    
                    try
                    {
                            if (!string.IsNullOrEmpty(Page.Request.Headers["devicetype"].ToString()))
                            {
                                    //      Response.Write("here3 ");
                                    deviceType = Page.Request.Headers["devicetype"].ToString();
                            }
                    }
                    catch (Exception hhh)
                    {
                            deviceType = "9500";
                    }
    
                    if (checkUsername())
                    {
                            
                            updateFields();
                            Response.Write("You are logged in");
                    }
                    else
                    {
                            Response.Write("Couldn't log you in");
                    }
                    }
                    catch(Exception ex)
                    {
                    Response.Write("Error "+ex);
                    }
                    }
    
            
          
    
    
        public Boolean checkUsername()
        {
                string connetionString = null;
               
                string sql = null;
               
                Boolean verified = false;
                connetionString = ConfigurationManager.AppSettings["ConnectionString"];
                sql = "SELECT * from users WHERE username = '" + username + "'" ;
                if (sql != null)
                {
    
                        cnn = new SqlConnection(connetionString);
                        try
                        {
                                cnn.Open();
                                cmd = new SqlCommand(sql, cnn);
    
                                reader = cmd.ExecuteReader();
    
                                if (reader.HasRows)
                                {
                                reader.Read();
                                         dbPassword = reader["password"].ToString();
                                         if(dbPassword.Equals(password))
                                         {
                                            verified =true;
                                         }
                                         else
                                         {
    
                                            verified = false;
                                         }
    
                                }
                                else
                                {
                                        verified = false;
                                }
                               
                        }
                        catch (Exception ex)
                        {
                                //MessageBox.Show("Can not open connection ! ");
                                Response.Write(ex);
                        }
                        finally
                        {
                                if (cmd != null)
                                        cmd.Dispose();
                                if (cnn != null)
                                        cnn.Close();
                                if (reader != null)
                                        reader.Close();;
                        }
                  
    
    
                }
                return verified;
        }
    
    
        public void updateFields()
        {
         
                try
                {
                        string constring = ConfigurationManager.AppSettings["ConnectionString"];
    
                         cnn = new SqlConnection(constring);
    
    
                        string myInsertQuery = "UPDATE [users] SET [password] = @textpassword, [deviceType] = @textDeviceType,  [phoneNumber] = @textPhoneNumber WHERE [username] = @username";   
    
                        
    
                         cmd = new SqlCommand(myInsertQuery, cnn);
                        
                        String one = password;
                        String two = deviceType;
                        String three = phoneNumber;
                            String user2 = username;
    
                        //String 8 = texttelephone.Text
                        cnn.Open();
                     
                        cmd.Parameters.AddWithValue("@textpassword", one);
                        cmd.Parameters.AddWithValue("@textDeviceType", two);
                        cmd.Parameters.AddWithValue("@textPhoneNumber", three);
                        cmd.Parameters.AddWithValue("@username", user2);
    
    
                        Int32 rowsAffected = cmd.ExecuteNonQuery();
                        // Alert.Show("here" + rowsAffected + one + five + nine);
                        
    
              
    
                }
                catch (Exception mm)
                {
                        Response.Write("Error " + mm);
                }
                finally
                {
                        if (cmd != null)
                                cmd.Dispose();
                        if (cnn != null)
                                cnn.Close();
                        if (reader != null)
                                reader.Close();
                }
    
    
    
    
        }
    
    }


     

    Wednesday, September 15, 2010 6:16 PM

All replies

  • User-174306217 posted

    can anyone at all please tell me why a request time out would occur after only a couple of seconds please? My project ca fail on this one issue.

     

    Regards

     

    Brendan 

    Thursday, September 16, 2010 3:43 AM