Link to home
Create AccountLog in
Avatar of Anandita Rani
Anandita Rani

asked on

Redirect URI cannot contain newline characters.

protected void btnsave_Click(object sender, EventArgs e)
    {
        try
        {
            using (SqlConnection cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString))
            using (SqlCommand cmm = new SqlCommand())
            {
                cmm.Connection = cnn;
                cmm.CommandType = CommandType.Text;
                if (btnsave.Text == "Save")
                {
                    cmm.CommandText = "INSERT INTO register_user([name],[email],[email_pass],[panel_pass],[dept])" + "VALUES(@name,@email,@email_pass,@panel_pass,@dept)";
 
                    cmm.Parameters.AddWithValue("@name", txtname.Text.Trim().ToString());
                    cmm.Parameters.AddWithValue("@email", txtemail.Text.Trim().ToString());
                    cmm.Parameters.AddWithValue("@email_pass", txtemailpass.Text.Trim().ToString());
                    cmm.Parameters.AddWithValue("@panel_pass", txtpass.Text.Trim().ToString());
                    cmm.Parameters.AddWithValue("@dept", ddldept.Text.Trim().ToString());
                   
                }
 
                else
                {
                    cmm.CommandText = "UPDATE [register_user] SET name=@name,email=@email,email_pass=@email_pass,panel_pass=@panel_pass,dept=@dept where id=" + ViewState["id"];
 
                    cmm.Parameters.AddWithValue("@name", txtname.Text.Trim().ToString());
                    cmm.Parameters.AddWithValue("@email", txtemail.Text.Trim().ToString());
                    cmm.Parameters.AddWithValue("@email_pass", txtemailpass.Text.Trim().ToString());
                    cmm.Parameters.AddWithValue("@panel_pass", txtpass.Text.Trim().ToString());
                    cmm.Parameters.AddWithValue("@dept", ddldept.Text.Trim().ToString());
                   
                   
                 
                    }
                        cmm.Connection.Open();
                        cmm.ExecuteNonQuery();
                        cmm.Connection.Close();
 
                        ScriptManager.RegisterStartupScript(this, GetType(), "Success", "alert('Information Save Successfully.');", true);
                    gvbind();
                    clear();
                }
            }
            catch (Exception ex)
            {
                Response.Redirect(ex.Message);
            }
 
    }


I am getting this error when my file is on server ,in localhost my code work fine. Please provide me solution for this
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Response.Redirect(ex.Message);

what are you trying to redirect here? redirect without a valid URL will generate another error.
Avatar of Anandita Rani
Anandita Rani

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).
I redirect to another another which is error page,now i do not get Redirect-URI-cannot-contain-newline-characters  error,  but i don't know my code work perfect locally , but give error on server.
ASKER CERTIFIED SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer