惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

W
WeLiveSecurity
T
Tenable Blog
Project Zero
Project Zero
C
Cybersecurity and Infrastructure Security Agency CISA
T
The Exploit Database - CXSecurity.com
P
Palo Alto Networks Blog
S
Schneier on Security
Scott Helme
Scott Helme
S
Securelist
Know Your Adversary
Know Your Adversary
Vercel News
Vercel News
IT之家
IT之家
V
V2EX
F
Fortinet All Blogs
Simon Willison's Weblog
Simon Willison's Weblog
K
Kaspersky official blog
博客园_首页
T
Tailwind CSS Blog
The GitHub Blog
The GitHub Blog
Spread Privacy
Spread Privacy
Microsoft Security Blog
Microsoft Security Blog
Cisco Talos Blog
Cisco Talos Blog
The Register - Security
The Register - Security
有赞技术团队
有赞技术团队
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Cyberwarzone
Cyberwarzone
Google DeepMind News
Google DeepMind News
The Hacker News
The Hacker News
L
LINUX DO - 热门话题
Hugging Face - Blog
Hugging Face - Blog
博客园 - 三生石上(FineUI控件)
A
Arctic Wolf
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
C
CXSECURITY Database RSS Feed - CXSecurity.com
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
T
Threat Research - Cisco Blogs
P
Proofpoint News Feed
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
P
Privacy & Cybersecurity Law Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
C
CERT Recently Published Vulnerability Notes
S
SegmentFault 最新的问题
AWS News Blog
AWS News Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
罗磊的独立博客
Apple Machine Learning Research
Apple Machine Learning Research
P
Proofpoint News Feed
The Cloudflare Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
Vulnerabilities – Threatpost

博客园 - buru

django begining Update 两个表之间更新数据问题 用户控件与应用页面的事件顺序 linq小问题总结 “尝试读取或写入受保护的内存”错误处理 firefox浏览器的默认事件 配置rails运行环境 通过c#和ironruby学习 ruby语言 SQL 语句查询与性能 操作Access数据库碰到的几个问题 asp.net的CodeDom zz天涯-关于职业生涯的 一个线程管理器 zz两个存储过程 看《C#线程参考手册》 Mediator 中介者模式 让firefox支持IE的一些属性 IE与firefox取得事件对象的函数(zz) proxy模式
c#通过url获取文件
buru · 2007-09-09 · via 博客园 - buru

很简单的一个Demo;

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    
<title>无标题页</title>
</head>
<body>
    
<form id="form1" runat="server">
    
<div>
        
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><asp:Button ID="Button1"
            runat
="server" Text="Button" OnClick="Button1_Click" />
    
</div>
    
</form>
</body>
</html>

//cs代码
using System;
using System.Web;
using System.Web.UI;
using System.IO;
using System.Net;
using System.Text;
public partial class _Default : System.Web.UI.Page 
{
    
protected void Page_Load(object sender, EventArgs e)
    
{

    }

    
protected void Button1_Click(object sender, EventArgs e)
    
{
        
string url = TextBox1.Text;
        HttpWebRequest req 
= (HttpWebRequest)WebRequest.Create(url);
        req.Referer 
= "http://";
       HttpWebResponse rs
=(HttpWebResponse) req.GetResponse();
       System.IO.Stream st 
= rs.GetResponseStream();
        
       FileStream fs 
= new FileStream(@"c:\xx.html", FileMode.Create, FileAccess.ReadWrite);
      st.Flush();

      
byte[] bt;
      StreamReader sr 
= new StreamReader(st);
      
string buffer=sr.ReadToEnd();
      bt 
= new System.Text.UTF8Encoding(true).GetBytes(buffer);
      fs.Write(bt, 
0, bt.Length);
      fs.Close();
            
    }

}