お読み頂きましてありがとうございます。
タイトルにもありますように、webbrowserにリファラーを設定してアクセスを行いたいのですが、下記のようにコードを書いたとしても実際にリファラーは反映されていない状態でした。
C#
1using System; 2using System.Collections.Generic; 3using System.ComponentModel; 4using System.Data; 5using System.Drawing; 6using System.Linq; 7using System.Text; 8using System.Threading.Tasks; 9using System.Runtime.InteropServices; 10using System.Windows.Forms; 11 12namespace WebbrowserRefererTest 13{ 14 public partial class Form1 : Form 15 { 16 [DllImport("urlmon.dll", CharSet = CharSet.Ansi)] 17 private static extern int UrlMkSetSessionOption(int dwOption, string str, int nLength, int dwReserved); 18 19 const string Url = "http://twiine.dousetsu.com/index1.html"; 20 public Form1() 21 { 22 const int URLMON_OPTION_USERAGENT = 0x10000001; 23 string ua = "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko"; 24 UrlMkSetSessionOption(URLMON_OPTION_USERAGENT, ua, ua.Length, 0); 25 26 InitializeComponent(); 27 webBrowser1.Navigate(Url, "", (byte[])null, "Referer: http://twiine.dousetsu.com/index1.html"); 28 } 29 } 30} 31
リンク元不詳となるのですが、上記ではなぜリファラーが設定されないのでしょうか?
回答2件
あなたの回答
tips
プレビュー