I have the following code to try sending a Http request to my test server:
var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost:5000/api/Logon");
request.Headers.Add("testheader", "1234");
var httpResponse = await Http.SendAsync(request);
But if I use Fiddler to see what is actual sent I get this in the Headers:
OPTIONS http://localhost:5000/api/Logon HTTP/1.1
Host: localhost:5000
Connection: keep-alive
Accept: */*
Access-Control-Request-Method: GET
Access-Control-Request-Headers: testheader
Origin: http://localhost:5005
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.104 Safari/537.36
Sec-Fetch-Mode: cors
Sec-Fetch-Site: same-site
Sec-Fetch-Dest: empty
Referer: http://localhost:5005/
Accept-Encoding: gzip, deflate, br
Accept-Language: en-GB,en-US;q=0.9,en;q=0.8
Why is it adding my custom header of 'testheader' to the Access-Control-Request-Headers?
question from:
https://stackoverflow.com/questions/65919505/sending-httprequest-from-blazor-webasembly 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…