My websites were facing 503 error. It seems to be due to the overcrowding of the application pool.
{
public MyFunction()
//
// TODO: Add constructor logic here
}
public static string ConnectionString
get
try
return System.Configuration.ConfigurationManager.ConnectionStrings["MyConnection"].ConnectionString;
catch (Exception ex)
throw new ApplicationException("Unable to get Database Connection string from Web Config File");
public static string Execute(string query)
int ret = 0;
SqlConnection con = new SqlConnection(Database.ConnectionString);
con.Open();
SqlCommand cmd = new SqlCommand(query, con);
ret = cmd.ExecuteNonQuery();
con.Close();
return ret.ToString();
return ex.Message.ToString();
public static string GenerateOTP(int length, string is_alpha_numeric)
string otp = "";
string alphabets = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string small_alphabets = "abcdefghijklmnopqrstuvwxyz";
string numbers = "1234567890";
string characters = numbers;
if (is_alpha_numeric == "1")
characters += alphabets + small_alphabets + numbers;
//int length = int.Parse(ddlLength.SelectedItem.Value);
otp = string.Empty;
for (int i = 0; i < length; i++)
string character = string.Empty;
do
int index = new Random().Next(0, characters.Length);
character = characters.ToCharArray()[index].ToString();
} while (otp.IndexOf(character) != -1);
otp += character;
return otp;
protected void btn_save_Click(object sender, EventArgs e)
string query = "";
int success = 0;
int error = 0;
string member_key = "";
string res = "";
for (int i = 0; i < 1500; i++)
repeat:
member_key = MyFunction.GenerateOTP(8, "1");
query = "Insert into [Person].[MemberCode]([MemberKey],[CreateDate]) values('" + member_key + "','" + DateTime.Now.ToShortDateString() + "')";
res = MyFunction.Execute(query);
if (res == "1")
success++;
else if (res.Contains("Violation of UNIQUE KEY constraint"))
goto repeat;
else
error++;
if (success > 0)
msg.InnerHtml = "<div class='msg msg-success'><strong>Success! </strong>" + success + " Member key has been created successfully.<br /></div>";
msg.InnerHtml = "<div class='msg msg-danger'><strong>Error! </strong>Technical error occured, please try later.<br /></div>";
msg.InnerHtml = "<div class='msg msg-danger'><strong>Error! </strong>Oops! Something went wrong, Please try again later.<br /></div>";