[*] В Windows 10, используя httpclient в C#: Я получаю «JavaScript отключен в вашем браузере»
[*] in windows 11, используя httpcient in windows 11, windows. Контент < /p>
< /li>
В Windows 10 с использованием curl: я получаю ожидаемый содержимое веб -страницы. Таким образом, я не понимаю, почему я не получаю такой же ответ от сервера в зависимости от программы /ОС.
Код: Выделить всё
curl -D curl-response-headers.txt -o curl-response-content.html -v https://weneverlearnedtolive.bandcamp.com/album/silently-i-threw-them-skyward 2> curl-request.log
< /code>
Вот результаты: < /p>
curl-request.logКод: Выделить всё
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
* Host weneverlearnedtolive.bandcamp.com:443 was resolved.
* IPv6: (none)
* IPv4: 151.101.1.91, 151.101.193.91, 151.101.65.91, 151.101.129.91
* Trying 151.101.1.91:443...
* schannel: disabled automatic use of client certificate
* ALPN: curl offers http/1.1
* ALPN: server accepted http/1.1
* Connected to weneverlearnedtolive.bandcamp.com (151.101.1.91) port 443
* using HTTP/1.x
> GET /album/silently-i-threw-them-skyward HTTP/1.1
> Host: weneverlearnedtolive.bandcamp.com
> User-Agent: curl/8.13.0
> Accept: */*
* Request completely sent off
< HTTP/1.1 200 OK
< Connection: keep-alive
< Content-Length: 304708
< server: nginx
< cache-control: no-cache, no-store
< content-type: text/html; charset=UTF-8
< link: ; rel="canonical"
< via: 1.1 varnish, 1.1 varnish
< referrer-policy: no-referrer-when-downgrade
< set-cookie: BACKENDID3=c2flexocentral-h0d1-5; path=/; Secure
< accept-ranges: bytes
< content-security-policy: base-uri 'none'; object-src 'none'; report-uri https://bandcamp.com/api/cspreport/1/violation; script-src http: https: 'nonce-s3hx8+at705S3MtOqJD9rA==' 'report-sample' 'strict-dynamic'
< Date: Sat, 04 Oct 2025 20:52:07 GMT
< X-Served-By: cache-par-lfpg1960032-PAR, cache-par-lfpg1960095-PAR
< X-Cache: MISS, MISS
< X-Cache-Hits: 0, 0
< X-Timer: S1759611127.329393,VS0,VE632
< Vary: Accept-Encoding, Accept-Encoding
< Strict-Transport-Security: max-age=63072000
<
{ [1371 bytes data]
10 297k 10 32059 0 0 44258 0 0:00:06 --:--:-- 0:00:06 44341
100 297k 100 297k 0 0 311k 0 --:--:-- --:--:-- --:--:-- 311k
* Connection #0 to host weneverlearnedtolive.bandcamp.com left intact
< /code>
curl-response-content.htmlКод: Выделить всё
Silently, I Threw Them Skyward | We Never Learned To Live
[...]
[...]
< /code>
[b]Using C# and HttpClientТеперь, когда я хочу загрузить ту же веб -страницу, используя httpclient в C#, я не получаю контент веб -страницы, а на веб -странице, в которой говорится, что «JavaScript отключен в вашем браузере». Рассмотрим следующий код C#, используя .net 4.8 (результаты одинаковы с .net 8.0): < /p>
Код: Выделить всё
using System.IO;
using System.Net.Http;
var httpClient = new HttpClient();
// Mimicing the curl headers
httpClient.DefaultRequestHeaders.Add("Host", "weneverlearnedtolive.bandcamp.com");
httpClient.DefaultRequestHeaders.Add("User-Agent", "curl/8.13.0");
httpClient.DefaultRequestHeaders.Add("Accept", "*/*");
var htmlCode = await httpClient.GetStringAsync("https://weneverlearnedtolive.bandcamp.com/album/silently-i-threw-them-skyward");
File.WriteAllText(@"C:\temp\httpclient-response.html", htmlCode);
< /code>
Вот результаты: < /p>
httpclient-response.htmlКод: Выделить всё
Client Challenge
#loading-error {
font-size: 16px;
font-family: 'Inter', sans-serif;
margin-top: 10px;
margin-left: 10px;
display: none;
}
[img]/_fs-ch-1T1wmsGaOgGaSxcX/assets/errorIcon.svg[/img]
alt=""
role="presentation"
class="error-icon"
/>
JavaScript is disabled in your browser.
Please enable JavaScript to proceed.
A required part of this site couldn’t load. This may be due to a browser
extension, network issues, or browser settings. Please check your
connection, disable any ad blockers, or try using a different browser.
function loadScript(src) {
return new Promise((resolve, reject) => {
const script = document.createElement('script');
script.onload = resolve;
script.onerror = (event) => {
console.error('Script load error event:', event);
document.getElementById('loading-error').style.display = 'block';
loadingError.setAttribute('aria-hidden', 'false');
reject(
new Error(
`Failed to load script: ${src}, Please contact the service administrator.`
)
);
};
script.src = src;
document.body.appendChild(script);
});
}
loadScript('/_fs-ch-1T1wmsGaOgGaSxcX/errors.js')
.then(() => {
const script = document.createElement('script');
script.src = '/_fs-ch-1T1wmsGaOgGaSxcX/script.js?reload=true';
script.onerror = (event) => {
console.error('Script load error event:', event);
const errorMsg = new Error(
`Failed to load script: ${script.src}. Please contact the service administrator.`
);
console.error(errorMsg);
handleScriptError();
};
document.body.appendChild(script);
})
.catch((error) => {
console.error(error);
});
< /code>
I've enabled Network Tracing and this is the result:
Complete log, too long to post here: https://pastebin.com/0EKbmPUv - extract:
System.Net.Http Verbose: 0 : [7800] Entering HttpClientHandler#45004109::.ctor()
System.Net.Http Verbose: 0 : [7800] Exiting HttpClientHandler#45004109::.ctor()
System.Net Information: 0 : [7800] Current OS installation type is 'Client'.
System.Net.Http Verbose: 0 : [7800] Entering HttpClient#2383799::.ctor(HttpClientHandler#45004109)
System.Net.Http Information: 0 : [7800] Associating HttpClient#2383799 with HttpClientHandler#45004109
System.Net.Http Verbose: 0 : [7800] Exiting HttpClient#2383799::.ctor()
System.Net.Http Verbose: 0 : [7800] Entering HttpClient#2383799::.ctor(HttpClientHandler#45004109)
System.Net.Http Verbose: 0 : [7800] Exiting HttpClient#2383799::.ctor()
System.Net.Http Verbose: 0 : [7800] Entering HttpRequestMessage#21454193::.ctor(Method: GET, Uri: 'https://weneverlearnedtolive.bandcamp.com/album/silently-i-threw-them-skyward')
System.Net.Http Verbose: 0 : [7800] Exiting HttpRequestMessage#21454193::.ctor()
System.Net.Http Verbose: 0 : [7800] Entering HttpClient#2383799::SendAsync(HttpRequestMessage#21454193: Method: GET, RequestUri: 'https://weneverlearnedtolive.bandcamp.com/album/silently-i-threw-them-skyward', Version: 1.1, Content: , Headers:
{
Host: weneverlearnedtolive.bandcamp.com
User-Agent: curl/8.13.0
Accept: */*
})
System.Net.Http Verbose: 0 : [7800] Entering HttpClientHandler#45004109::SendAsync(HttpRequestMessage#21454193)
[...]
System.Net Information: 0 : [7720] HttpWebRequest#58870012 - Request: GET /album/silently-i-threw-them-skyward HTTP/1.1
System.Net Information: 0 : [7720] ConnectStream#17653682 - Sending headers
{
User-Agent: curl/8.13.0
Accept: */*
Host: weneverlearnedtolive.bandcamp.com
Connection: Keep-Alive
}.
[...]
System.Net.Http Information: 0 : [7720] HttpClient#2383799 - Request for HttpRequestMessage#21454193 completed successfully. Returning response HttpResponseMessage#41488021: StatusCode: 200, ReasonPhrase: 'OK', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
Connection: keep-alive
link: ; rel="canonical"
referrer-policy: no-referrer-when-downgrade
content-security-policy: base-uri 'none'; object-src 'none'; report-uri https://bandcamp.com/api/cspreport/1/violation; script-src http: https: 'nonce-4SNicugooCStEQCJ71zXaQ==' 'report-sample' 'strict-dynamic'
X-Served-By: cache-par-lfpg1960097-PAR, cache-par-lfpg1960046-PAR
X-Cache: MISS, MISS
X-Cache-Hits: 0, 0
X-Timer: S1759615346.832943,VS0,VE403
Vary: Accept-Encoding
Vary: Accept-Encoding
Strict-Transport-Security: max-age=63072000
Accept-Ranges: bytes
Cache-Control: no-store, no-cache
Date: Sat, 04 Oct 2025 22:02:26 GMT
Set-Cookie: BACKENDID3=flexocentral-wqtw-4; path=/; Secure
Server: nginx
Via: 1.1 varnish
Via: 1.1 varnish
Content-Length: 304704
Content-Type: text/html; charset=UTF-8
}
< /code>
[b]Using C# HttpClientс той же программой, построенной на Windows 10, но работал на Windows 11, я получаю ожидаемый содержимое веб -страницы.
Код: Выделить всё
httpclient-response.htmlКод: Выделить всё
Silently, I Threw Them Skyward | We Never Learned To Live
[...]
[...]
< /code>
Here's the result of Network Tracing - complete log, too long to post here: https://pastebin.com/sicHJsRZ - extract:
System.Net.Http Verbose: 0 : [21888] Entering HttpClientHandler#45004109::.ctor()
System.Net.Http Verbose: 0 : [21888] Exiting HttpClientHandler#45004109::.ctor()
System.Net Information: 0 : [21888] Current OS installation type is 'Client'.
System.Net.Http Verbose: 0 : [21888] Entering HttpClient#2383799::.ctor(HttpClientHandler#45004109)
System.Net.Http Information: 0 : [21888] Associating HttpClient#2383799 with HttpClientHandler#45004109
System.Net.Http Verbose: 0 : [21888] Exiting HttpClient#2383799::.ctor()
System.Net.Http Verbose: 0 : [21888] Entering HttpClient#2383799::.ctor(HttpClientHandler#45004109)
System.Net.Http Verbose: 0 : [21888] Exiting HttpClient#2383799::.ctor()
System.Net.Http Verbose: 0 : [21888] Entering HttpRequestMessage#21454193::.ctor(Method: GET, Uri: 'https://weneverlearnedtolive.bandcamp.com/album/silently-i-threw-them-skyward')
System.Net.Http Verbose: 0 : [21888] Exiting HttpRequestMessage#21454193::.ctor()
System.Net.Http Verbose: 0 : [21888] Entering HttpClient#2383799::SendAsync(HttpRequestMessage#21454193: Method: GET, RequestUri: 'https://weneverlearnedtolive.bandcamp.com/album/silently-i-threw-them-skyward', Version: 1.1, Content: , Headers:
{
Host: weneverlearnedtolive.bandcamp.com
User-Agent: curl/8.13.0
Accept: */*
})
System.Net.Http Verbose: 0 : [21888] Entering HttpClientHandler#45004109::SendAsync(HttpRequestMessage#21454193)
[...]
System.Net Information: 0 : [20256] HttpWebRequest#58870012 - Request: GET /album/silently-i-threw-them-skyward HTTP/1.1
System.Net Information: 0 : [20256] ConnectStream#11429296 - Sending headers
{
User-Agent: curl/8.13.0
Accept: */*
Host: weneverlearnedtolive.bandcamp.com
Connection: Keep-Alive
}.
[...]
System.Net.Http Information: 0 : [4128] HttpClient#2383799 - Request for HttpRequestMessage#21454193 completed successfully. Returning response HttpResponseMessage#23264094: StatusCode: 200, ReasonPhrase: 'OK', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
Connection: keep-alive
X-Served-By: cache-par-lfpg1960078-PAR, cache-par-lfpg1960098-PAR
X-Cache: MISS
X-Cache-Hits: 0
X-Timer: S1759613754.880187,VS0,VE16
Strict-Transport-Security: max-age=63072000
transfer-encoding: chunked
Accept-Ranges: bytes
Cache-Control: no-store, private
Date: Sat, 04 Oct 2025 21:35:53 GMT
Set-Cookie: _fs_ch_st_FSBmUei20MqUiJb9=AVIj7A7j2xFzZyiA6fSINoRRHZoXZ7qHAUlwGmE46LFeJCBixSX5CHJMrGIm8hu65hsZSfU8SoXi3p2you36fsZzgfzG0ZJdwJu8YIwe_vX5qQ89btc5ODfHlaoyAb4oIWPtu8_khLIO_SlUbNwjnxN4AmiWWDKLeH7L418co2tEcKOWpVYQDb6t7JgntY0NurpWPo6IitDzoBCM7arYoFAE_rvExvTSinP77GKGOtUGZCkAhutKOUprWNyYC8g91a7_JJPLiFcF03RqN14wfP1tSlojV7CJbBKyVIV_zz88Mo2F4-G9hbI-ngZOTgEPcP9fW9VPnTqoAiIvAQ==; Max-Age=10; HttpOnly; Path=/
Via: 1.1 varnish
Content-Type: text/html; charset=utf-8
}
< /code>
[b]My conclusion[/b]
The HTTP version logged is the same (HTTP 1.1), I've set the same headers as curl does and I don't see the .NET Framework adding other headers when I analyze the traffic using a proxy like Fiddler or mitmproxy or even when analyzing packets with Wireshark:
[img]https://i.sstatic.net/7oYjLwce.png[/img]
Thus I don't see what could differentiate the requests in order for the server to send a different response. In the end, I'd like to get the expected webpage content on Windows 10 with the HttpClientЭто поведение является новым с 2025-09-24, я правильно загрузил веб-страницу до этой даты, поэтому я думаю, что они должны были изменить что-то на стороне сервера. Получение ожидаемого контента веб -страницы. Но это не решение для меня, потому что я застрял в Net48 и http 2 не поддерживается.
Когда я пытаюсь заставить HTTP 2 с curl , я получаю следующую ошибку, поэтому он подтверждает Curl не лжет, когда он регистрирует HTTP 1.1 :
curl --http2 https://weneverlearnedtolive.bandcamp.c ... em-skyward
curl: option --http2: the installed libcurl version does not support this
< /code>
< /li>
< /ul>
Извините за длинный пост, я надеюсь, что кто -то сможет просветить меня.
Подробнее здесь: https://stackoverflow.com/questions/797 ... st-between
Мобильная версия