[Solved] ASP.Net MVC Error: Redirect URI cannot contain newline characters

ramco1917
 
on Jul 16, 2021 12:19 AM
596 Views

Hi

Error: Redirect URI cannot contain newline characters

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

Download FREE API for Word, Excel and PDF in ASP.Net: Download
dharmendr
 
on Jul 16, 2021 03:40 AM

Use HttpUtility.UrlEncode.

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