我在asp.net页面(在服务器上运行)中使用webrequest来获取谷歌驱动器直接下载链接。之后,我将此链接发送给客户端(他们使用浏览器ex:chrome,firefox)下载此文件。但是issuie是cookie,webrequest cookie和客户端cookie不一样。当然他们无法下载。 那么,我如何将webrequest cookie设置为客户端? 或者如何使webrequest cookie和客户端cookie相同?感谢并希望有一些想法来解决这个问题。这是我的代码:
HttpWebRequest objWebRequest = (HttpWebRequest)WebRequest.Create(url);
objWebRequest.CookieContainer = cookies;
objWebRequest.Credentials = CredentialCache.DefaultCredentials;
HttpWebResponse objWebResponse = (HttpWebResponse)objWebRequest.GetResponse();
Stream receiveStream = objWebResponse.GetResponseStream();
StreamReader readStream = new StreamReader(receiveStream, System.Text.Encoding.UTF8);
HtmlAgilityPack.HtmlDocument doc = new HtmlDocument();
doc.Load(readStream);
string link = ""; //=> this link i need to send client
foreach (HtmlNode row in doc.DocumentNode.SelectNodes("//a[@id='uc-download-link']"))
{ link += row.Attributes["href"].Value; }