question

JagjitSaini-0360 avatar image
0 Votes"
JagjitSaini-0360 asked Bruce-SqlWork answered

Redirect URI cannot contain newline characters.

Hi

protected void Application_Error(object sender, EventArgs e)
{
Exception exception = Server.GetLastError();
if (exception != null)
{
HttpException httpException = null;
if (exception is HttpException)
{
httpException = exception as HttpException;
}

             Response.Clear();
             Server.ClearError();
             Response.Redirect(String.Format("~/Error/Index/?message={0}", exception.Message));
         }
     }

Thanks

dotnet-aspnet-mvc
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Bruce-SqlWork avatar image
0 Votes"
Bruce-SqlWork answered

In the following line

 Response.Redirect(String.Format("~/Error/Index/?message={0}", exception.Message));

You need to url encode the message.

 Response.Redirect(String.Format("~/Error/Index/?message={0}", Server.UrlEncode(exception.Message)));
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

YijingSun-MSFT avatar image
0 Votes"
YijingSun-MSFT answered

Hi @JagjitSaini-0360 ,

Redirect URI cannot contain newline characters.

Where is the newline characters? I have tried the codes of Response.Redirect and it works fine.
You could check which lines have errors.
Best regards,
Yijing Sun

If the answer is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our  documentation  to enable e-mail notifications if you want to receive the related email notification for this thread.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.