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

推荐订阅源

Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 【当耐特】
T
Tailwind CSS Blog
Microsoft Azure Blog
Microsoft Azure Blog
爱范儿
爱范儿
P
Proofpoint News Feed
博客园_首页
博客园 - 聂微东
人人都是产品经理
人人都是产品经理
GbyAI
GbyAI
AI
AI
云风的 BLOG
云风的 BLOG
有赞技术团队
有赞技术团队
SecWiki News
SecWiki News
Google Online Security Blog
Google Online Security Blog
W
WeLiveSecurity
V
V2EX
K
Kaspersky official blog
Security Archives - TechRepublic
Security Archives - TechRepublic
Security Latest
Security Latest
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
NISL@THU
NISL@THU
C
CERT Recently Published Vulnerability Notes
大猫的无限游戏
大猫的无限游戏
G
GRAHAM CLULEY
H
Help Net Security
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Blog — PlanetScale
Blog — PlanetScale
V
Vulnerabilities – Threatpost
Recent Announcements
Recent Announcements
aimingoo的专栏
aimingoo的专栏
T
The Blog of Author Tim Ferriss
WordPress大学
WordPress大学
博客园 - 司徒正美
V
Visual Studio Blog
L
Lohrmann on Cybersecurity
C
Cisco Blogs
A
About on SuperTechFans
N
News | PayPal Newsroom
Last Week in AI
Last Week in AI
Martin Fowler
Martin Fowler
罗磊的独立博客
A
Arctic Wolf
Hacker News - Newest:
Hacker News - Newest: "LLM"
S
Secure Thoughts
AWS News Blog
AWS News Blog
TaoSecurity Blog
TaoSecurity Blog
T
Tenable Blog
Engineering at Meta
Engineering at Meta

博客园 - 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();
            
    }

}