Anandita Rani
asked on
Redirect URI cannot contain newline characters.
protected void btnsave_Click(object sender, EventArgs e)
{
try
{
using (SqlConnection cnn = new SqlConnection(Configuratio nManager.C onnectionS trings["Co nnectionSt ring"].Con nectionStr ing))
using (SqlCommand cmm = new SqlCommand())
{
cmm.Connection = cnn;
cmm.CommandType = CommandType.Text;
if (btnsave.Text == "Save")
{
cmm.CommandText = "INSERT INTO register_user([name],[emai l],[email_ pass],[pan el_pass],[ dept])" + "VALUES(@name,@email,@emai l_pass,@pa nel_pass,@ dept)";
cmm.Parameters.AddWithValu e("@name", txtname.Text.Trim().ToStri ng());
cmm.Parameters.AddWithValu e("@email" , txtemail.Text.Trim().ToStr ing());
cmm.Parameters.AddWithValu e("@email_ pass", txtemailpass.Text.Trim().T oString()) ;
cmm.Parameters.AddWithValu e("@panel_ pass", txtpass.Text.Trim().ToStri ng());
cmm.Parameters.AddWithValu e("@dept", ddldept.Text.Trim().ToStri ng());
}
else
{
cmm.CommandText = "UPDATE [register_user] SET name=@name,email=@email,em ail_pass=@ email_pass ,panel_pas s=@panel_p ass,dept=@ dept where id=" + ViewState["id"];
cmm.Parameters.AddWithValu e("@name", txtname.Text.Trim().ToStri ng());
cmm.Parameters.AddWithValu e("@email" , txtemail.Text.Trim().ToStr ing());
cmm.Parameters.AddWithValu e("@email_ pass", txtemailpass.Text.Trim().T oString()) ;
cmm.Parameters.AddWithValu e("@panel_ pass", txtpass.Text.Trim().ToStri ng());
cmm.Parameters.AddWithValu e("@dept", ddldept.Text.Trim().ToStri ng());
}
cmm.Connection.Open();
cmm.ExecuteNonQuery();
cmm.Connection.Close();
ScriptManager.RegisterStar tupScript( this, GetType(), "Success", "alert('Information Save Successfully.');", true);
gvbind();
clear();
}
}
catch (Exception ex)
{
Response.Redirect(ex.Messa ge);
}
}
I am getting this error when my file is on server ,in localhost my code work fine. Please provide me solution for this
{
try
{
using (SqlConnection cnn = new SqlConnection(Configuratio
using (SqlCommand cmm = new SqlCommand())
{
cmm.Connection = cnn;
cmm.CommandType = CommandType.Text;
if (btnsave.Text == "Save")
{
cmm.CommandText = "INSERT INTO register_user([name],[emai
cmm.Parameters.AddWithValu
cmm.Parameters.AddWithValu
cmm.Parameters.AddWithValu
cmm.Parameters.AddWithValu
cmm.Parameters.AddWithValu
}
else
{
cmm.CommandText = "UPDATE [register_user] SET name=@name,email=@email,em
cmm.Parameters.AddWithValu
cmm.Parameters.AddWithValu
cmm.Parameters.AddWithValu
cmm.Parameters.AddWithValu
cmm.Parameters.AddWithValu
}
cmm.Connection.Open();
cmm.ExecuteNonQuery();
cmm.Connection.Close();
ScriptManager.RegisterStar
gvbind();
clear();
}
}
catch (Exception ex)
{
Response.Redirect(ex.Messa
}
}
I am getting this error when my file is on server ,in localhost my code work fine. Please provide me solution for this
ASKER
can you Provide me valid URL..
can you Provide me valid URL..this doesn't make sense. you got to know what you're going to do next after catching an exception, whether you're going to write the error message into a log file, or doing some redirection in your case (you got to provide and redirect to a page name).
ASKER
I redirect to another another which is error page,now i do not get Redirect-URI-cannot-contai n-newline- characters error, but i don't know my code work perfect locally , but give error on server.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
what are you trying to redirect here? redirect without a valid URL will generate another error.