GET with umlauts: DecoderFallbackException + 200 OK status returned
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 276
Description
### Describe the bug
```cs
[Route("api/[controller]")]
[ApiController]
public class StädteController : ControllerBase
{
// GET api/values
[HttpGet]
public ActionResult Get()
{
return new[] {"München", "Nürnberg"};
}
// POST api/values
[HttpPost]
public ActionResult Post([FromBody] string[] values)
{
return values;
}
}
```
### To Reproduce
Postman v7.2.2:
**GET**: https://localhost:44301/api/Städte
→ 200 OK
(no content returned)
Visual Studios Debug window:
>Microsoft.AspNetCore.Server.IIS.Core.IISHttpServer:Error: Unexpected exception in IISHttpServer.HandleRequest.
>
>System.Text.DecoderFallbackException: Unable to translate bytes [E4] at index 6 from specified code page to Unicode.
> at System.Text.DecoderExceptionFallbackBuffer.Throw(Byte[] bytesUnknown, Int32 index)
> at System.Text.DecoderExceptionFallbackBuffer.Fallback(Byte[] bytesUnknown, Int32 index)
> at System.Text.DecoderFallbackBuffer.InternalFallback(Byte[] bytes, Byte* pBytes)
> at System.Text.UTF8Encoding.GetCharCount(Byte* bytes, Int32 count, DecoderNLS baseDecoder)
> at System.String.CreateStringFromEncoding(Byte* bytes, Int32 byteLength, Encoding encoding)
> at System.Text.UTF8Encoding.GetString(Byte[] bytes, Int32 index, Int32 count)
> at Microsoft.AspNetCore.HttpSys.Internal.RequestUriBuilder.DecodeAndUnescapePath(Byte[] rawUrlBytes)
> at Microsoft.AspNetCore.Server.IIS.Core.IISHttpContext.GetOriginalPath()
> at Microsoft.AspNetCore.Server.IIS.Core.IISHttpContext.InitializeContext()
> at Microsoft.AspNetCore.Server.IIS.Core.IISHttpContextOfT`1.ProcessRequestAsync()
> at Microsoft.AspNetCore.Server.IIS.Core.IISHttpServer.HandleRequest(IISHttpContext context)
### Expected behavior
**GET**: https://localhost:44301/api/Städte
→ 200 OK
→ `["München","Nürnberg"]`
### Additional context
**THIS WORKS:**
**POST**: https://localhost:44301/api/Städte ["München","Nürnberg"]
→ 200 OK
→ `["München","Nürnberg"]`
WebApplication2.csproj:
```
netcoreapp2.2
InProcess
```
Contributor guide
Assessment
This issue has not been assessed yet.