VB.NET - WebBrowser 附加標題 - 用戶代理覆蓋/取消其他標題? (VB.NET - WebBrowser Additional Headers - User Agent Overrides / Cancels Other Headers?)


問題描述

VB.NET ‑ WebBrowser 附加標題 ‑ 用戶代理覆蓋/取消其他標題? (VB.NET ‑ WebBrowser Additional Headers ‑ User Agent Overrides / Cancels Other Headers?)

I am trying to add 2 things into a WebBrowser control request: 1) User Agent, 2) Referring URL, (Optional 3): Accept Type.

My Code:

Dim Headers As String = "Accept: */*" & Chr(10) & Chr(13)
Headers = Headers & "Referer: " & "http://www.google.com/" & Chr(10) & Chr(13)
Headers = Headers & "User‑Agent: " & "My Program User Agent" & Chr(10) & Chr(13)
WebBrowser1.Navigate(UrlToVisit, "_self", Nothing, Headers)

The above code ONLY sends the user agent. If I remove the user agent then the Accept & The referring URL are both set.

It seems that whenever I add in the user agent additional header any other custom additional headers are being cancelled out.

Is this a bug with WebBrowser / something that is not possible to do or am I doing something seriously wrong here!?!

‑‑‑‑‑

參考解法

方法 1:

EDIT: Worked out the issue moments afterwards ‑ My Useragent which was coming from a textbox had an additional vbcrlf causing the other headers not to work, after trimming this all working ok :)

方法 2:

Another note: you set chr(10) & chr(13) when it should be the other way round. CRLF as in the http standard means chr(13) & chr(10)

(by ChrisChrisBuggy)

參考文件

  1. VB.NET ‑ WebBrowser Additional Headers ‑ User Agent Overrides / Cancels Other Headers? (CC BY‑SA 3.0/4.0)

#referrer #Browser #vb.net #user-agent






相關問題

Can I render content dynamically within an iPhone app according to the referrer to my app in iTune appstore (Can I render content dynamically within an iPhone app according to the referrer to my app in iTune appstore)

BroadcastReceiver 沒有捕捉到 INSTALL_REFERRER 廣播 (BroadcastReceiver not catching the INSTALL_REFERRER broadcast)

Android INSTALL_REFERRER 和 Google Play 商店 (Android INSTALL_REFERRER and Google Play Store)

如何確定氮氣中的referer? (How to determine referer in Nitrogen?)

перанакіравальнік або ананімны клон (redirector or anony clone)

是否可以通過 Google Play 跟踪應用推薦人? (is it possible to tracking App Referrers NOT with Google Play?)

VB.NET - WebBrowser 附加標題 - 用戶代理覆蓋/取消其他標題? (VB.NET - WebBrowser Additional Headers - User Agent Overrides / Cancels Other Headers?)

HTTP 引薦來源網址陷阱? (HTTP Referrer Gotchas?)

在 jquery 重定向後在 asp.net mvc 中找到引用頁面 (find referring page in asp.net mvc after a jquery redirect)

Javascript 路徑名引用者 (Javascript pathname referrer)

沒有推薦人的請求最常見的原因是什麼? (What are the most common reasons for requests without referrer?)

有沒有辦法修復推薦人:301 錯誤沒有? (Is there a way to fix the referrer: none for a 301 error?)







留言討論