有一个frame页面用框架做的
框架包括一个头页面.一个pdf
我直接访问pdf不能下载.应该是通过cookie,session验证的.
我用httpresponse加cookie也无法下载.
所以求助webbroswer下访问那个frame页面后.通过webbroswer下载文件的方式!谢谢
框架包括一个头页面.一个pdf
我直接访问pdf不能下载.应该是通过cookie,session验证的.
我用httpresponse加cookie也无法下载.
所以求助webbroswer下访问那个frame页面后.通过webbroswer下载文件的方式!谢谢
解决方案 »
- 输入验证类,继承问题
- 关于LinkList一个问题
- 比如现在有字符串 "20081225"加上六个月后值。要怎么求。在线等
- 怎样在窗体程序中修改数据库内容后同时数据库更新
- Update 无法找到 TableMapping['Table'] 或 DataTable“Table”。
- XtraTreeList,如果其各子行与父行是不同的数据源,好不好实现?
- 在“我在电脑”中使用右键启动,并得到所有选择文件
- socket异步连接会导致程序卡死
- 如何改变ide的字体?
- post数据图片上传到指定的url下,老是报500的错
- 数字char转成数字byte
- 请教关于读写锁的问题,关于AcquireWriterLock取值为-1
2.如果用webbroswer,那就一句话的事。关键是你要开一个线程等那个完成后再下载第二个pdf
2.webbroswer给个代码吧.我给的分不低呀~
object j;
for (int i = 0; i < doc.parentWindow.frames.length; i++)
{
j = i;
HTMLWindow2Class frame = doc.parentWindow.frames.item(ref j) as HTMLWindow2Class;
if (frame.name == "main")
{
MessageBox.Show(frame.document.title);
}
}
3.获取frame的IHTMLDocument2接口IHTMLDocument2 doc = (IHTMLDocument2)webBrowser1.Document.Window.Frames["main"].Document.DomDocument;4.取得frame中被点击的连接private void webBrowser1_Navigating(object sender, WebBrowserNavigatingEventArgs e)
{
string url = webBrowser1.Document.Window.Frames["main"].Document.ActiveElement.GetAttribute("src");
}
原贴,原出处:http://blog.csdn.net/llj1985/archive/2007/09/01/1768147.aspx
System.IO.FileInfo file = new FileInfo(path);
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.Default;
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + t);HttpContext.Current.Response.AddHeader("Content-Length", file.Length.ToString());HttpContext.Current.Response.ContentType = "application/octet-stream";
HttpContext.Current.Response.WriteFile(file.FullName);
HttpContext.Current.Response.End();用上面的代码,就算aspx页面也可以下载了。
private void Form1_Load(object sender, EventArgs e)
{
this.webBrowser1.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webBrowser1_DocumentCompleted);
this.webBrowser1.Navigate("http://www.baidu.com");
} void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{ if (bFirst)
{
bFirst = false;
this.webBrowser1.Navigate("http://www.google.com");
}
else
{
MessageBox.Show(this.webBrowser1.DocumentText);
}
}
试试用 Fiddler2 软件抓下 http 包, 分析下用 httpwebrequest 完全 模拟 http 包 发送, 肯定是能实现的
System.Net.WebClient web = new System.Net.WebClient();
web.DownloadString("http://www.baidu.com");
web.DownloadFile("http://www.baidu.com/aa.pdf", "dd:\aa.pdf");
抓过的.cookie一个不差的发过去还是不行.
==>
把地址发过来试试?
private void button1_Click(object sender, EventArgs e)
{
WebClient DownFile=new WebClient();
DownFile.DownloadFile(@"", @"");
}
不需要发送cookie可直接下载
webbrower 跨iframe
http://msdn.microsoft.com/en-us/library/ms537182(VS.85).aspx
下载的只是错误页面的html