国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

小偷程序(ASP.NET+c#)

2024-07-10 13:00:08
字體:
來源:轉載
供稿:網友
  
在.net 平臺下,創建一個asp.net的程序
1、引用兩個namespace
      using system.text     //因為用了encoding類
      using system.net      //因為用了webclient 類
2、整個程序用了三個控件
      txturl    //輸入你要獲取的網頁地址 textbox控件
      txtbody  //得到你要獲取的網頁內容 textbox控件
      btnreturn  //按鈕button控件
3、在***.aspx.cs下的代碼
private void btnreturn_click(object sender, system.eventargs e)
  {
    string url=txturl.text.trim();    //獲取輸入的網頁地址

    webclient wb=new webclient();  //創建一個webclient實例
    //獲取或設置用于對向 internet 資源的請求進行身份驗證的網絡憑據。(可有可無)
    //wb.credentials=credentialcache.defaultcredentials; 
    //從資源下載數據并返回字節數組。(加@是因為網址中間有"/"符號)
    byte[] pagedata=wb.downloaddata(@url);
     //轉換字符、
    string result=encoding.default.getstring(pagedata);

    txtbody.text=result; 
  }
4、字***.aspx的html代碼中加入一條代碼
     在第一行代碼<%@ page=.............................%> 中加入validaterequest=false
總結:整個代碼不過才幾行,而且還不用操心亂碼的事情,我是昨天自己在幫助文檔里偶然看見的,其實webclient類有很多下載資源和上載資源的方法,有興趣的朋友可以看看下面有關webclient類的幫助文檔:
webclient 類請參見
webclient 成員 | system.net 命名空間 | webrequest | webresponse | httpwebrequest | 
httpwebresponse | webclient 成員(visual j# 語法) | c++ 托管擴展編程 
要求
命名空間: system.net
平臺: windows 98, windows nt 4.0, windows me, windows 2000, windows xp home edition, windows xp 
professional, windows server 2003 系列
程序集: system (在 system.dll 中)
.net framework 安全性:  
webpermission,用于訪問所請求的 uri 或請求被重定向到的任何 uri。關聯的枚舉:connect。 
語言
c#
c++
jscript
visual basic
全部顯示
提供向 uri 標識的資源發送數據和從 uri 標識的資源接收數據的公共方法。不能繼承此類。
有關此類型所有成員的列表,請參閱 webclient 成員。
system.object
   system.marshalbyrefobject
      system.componentmodel.component
         system.net.webclient
[visual basic]
<comvisible(true)>
notinheritable public class webclient
   inherits component
[c#]
[comvisible(true)]
public sealed class webclient : component
[c++]
[comvisible(true)]
public __gc __sealed class webclient : public component
[jscript]
public
   comvisible(true)
class webclient extends component
線程安全
此類型的所有公共靜態(visual basic 中為 shared)成員對多線程操作而言都是安全的。但不保證任何實例
成員是線程安全的。
備注
webclient 類提供向 uri 標識的任何本地、intranet 或 internet 資源發送數據以及從這些資源接收數據的
公共方法。
webclient 類使用 webrequest 類提供對 internet 資源的訪問。webclient 實例可以通過任何已向 
webrequest.registerprefix 方法注冊的 webrequest 子代訪問數據。
注意   默認情況下,.net framework 支持以 http:、https: 和 file: 方案標識符開頭的 uri。
webclient 類提供四種將數據上載到資源的方法: 
openwrite 返回一個用于將數據發送到資源的 stream。 
uploaddata 將字節數組發送到資源并返回包含任何響應的字節數組。 
uploadfile 將本地文件發送到資源并返回包含任何響應的字節數組。 
uploadvalues 將 namevaluecollection 發送到資源并返回包含任何響應的字節數組。 
webclient 類還提供三種從資源下載數據的方法: 
downloaddata 從資源下載數據并返回字節數組。 
downloadfile 從資源將數據下載到本地文件。 
openread 從資源以 stream 的形式返回數據。 
要求
命名空間: system.net
平臺: windows 98, windows nt 4.0, windows me, windows 2000, windows xp home edition, windows xp 
professional, windows server 2003 系列
程序集: system (在 system.dll 中)
.net framework 安全性:  
webpermission,用于訪問所請求的 uri 或請求被重定向到的任何 uri。關聯的枚舉:connect。 

收集最實用的網頁特效代碼!

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 三原县| 简阳市| 深水埗区| 吴桥县| 沙河市| 道真| 海林市| 辰溪县| 霍城县| 宜兴市| 兖州市| 来凤县| 贵港市| 札达县| 新源县| 孝昌县| 阜宁县| 宝坻区| 商南县| 偃师市| 清水河县| 花莲市| 中方县| 西和县| 福建省| 东源县| 香港| 年辖:市辖区| 翁源县| 贞丰县| 靖州| 香港 | 岐山县| 仁寿县| 黑山县| 钟祥市| 襄樊市| 长治县| 临西县| 和田市| 且末县|