You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 18, 2018. It is now read-only.
When attempting to redirect to a URL containing a non-ASCII character, Kestrel throws the following exception:
System.InvalidOperationException: Invalid non-ASCII or control character in header: 0x00E7
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.FrameHeaders.ThrowInvalidHeaderCharacter(Char ch)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.FrameHeaders.ValidateHeaderCharacters(String headerCharacters)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.FrameHeaders.ValidateHeaderCharacters(StringValues headerValues)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.FrameResponseHeaders.SetValueFast(String key, StringValues value)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.FrameHeaders.Microsoft.AspNetCore.Http.IHeaderDictionary.set_Item(String key, StringValues value)
at Microsoft.AspNetCore.Http.Internal.DefaultHttpResponse.Redirect(String location, Boolean permanent)
at Microsoft.AspNetCore.Mvc.Internal.RedirectResultExecutor.Execute(ActionContext context, RedirectResult result)
at Microsoft.AspNetCore.Mvc.RedirectResult.ExecuteResult(ActionContext context)
at Microsoft.AspNetCore.Mvc.ActionResult.ExecuteResultAsync(ActionContext context)
Sample code:
[Route("[controller]")]
public class HomeController : Controller
{
[HttpGet]
public IActionResult Goto() => Redirect("http://example.com/façade.pdf");
}
The same Redirect works correctly on ASP.NET MVC 5.2.3.
I'm aware the HTTP don't allow non-ASCII character in the URL, but, this can be considered an bug? If no, what is the best recommendation here? Encode the URL before redirect?