hello i will get access few parameters from one web form to another one and i have used:
Response.Redirect("adpreview.aspx?email=" + txtEmail.Text + "&title=" + txtTitle.Text + "&message=" + lblResult.Text);
but i get this error: System.ArgumentException: Redirect URI cannot contain newline characters.
i reduced it to: Response.Redirect("adpreview.aspx?message=" + lblResult.Text);
but i got the same error... ???!!! how should i do? thanks your respond. kind regards
Mohamed Azarudeen ZPosted Jul 16, 2023, 6:08 AM
Hi venus
To resolve this issue, you can encode the query string parameters before appending them to the Redirect URI. Here's an example of how you can achieve this using the
HttpUtility.UrlEncodemethod in ASP.NET:By applying
HttpUtility.UrlEncodeto each query string parameter, any special characters or newline characters will be properly encoded, ensuring that the Redirect URI does not violate the URI syntax.if the answer helped kindly accept thanks
Amit MohantyPosted Jul 17, 2023, 6:05 AM
The error message you're encountering suggests that the Redirect URI you're using contains newline characters, which are not allowed. This is likely caused by the value of the lblResult.Text parameter in your code.