Asp.net| Procedure | Thief program
Under the. Net platform, create a asp.net program
1, quote two namespace
Using System.Text//Because of the encoding class
Using System.Net//Because of the WebClient class
2, the entire program with three controls
Txturl//Enter the page address TextBox control you want to get
Txtbody//Get the Web content you want to get the TextBox control
Btnreturn//Buttons Button control
3, the code under the ***.aspx.cs
private void Btnreturn_click (object sender, System.EventArgs e)
{
String Url=txturl.text.trim (); Get the page address you entered
WebClient wb=new WebClient (); Create a WebClient instance
Gets or sets the network credentials used to authenticate requests to Internet resources. Dispensable
Wb. Credentials=credentialcache.defaultcredentials;
Downloads data from a resource and returns a byte array. (add @ Because there is a "/" symbol in the middle of the URL)
Byte[] PAGEDATA=WB. Downloaddata (@url);
Convert characters,
String result=encoding.default.getstring (Pagedata);
Txtbody.text=result;
}
4, the word ***.aspx HTML code to add a code
Add Validaterequest=false in the first line of code <%@ page=.............................%>
Summary: The entire code but only a few lines, and do not worry about garbled things, I was yesterday in the help document accidentally saw, in fact, WebClient class has a lot of download resources and upload resources methods, interested friends can look at the following about the WebClient class help documents:
WebClient class See
WebClient Members | System.Net Namespaces | WebRequest | WebResponse | HttpWebRequest |
HttpWebResponse | WebClient Member (Visual J # Syntax) | Managed Extensions for C + + programming
Requirements
Namespaces: System.Net
Platforms: Windows, Windows NT 4.0, Windows ME, Windows XP, Windows xp-based Home Edition, Windows XP
Professional, Windows Server 2003 series
Assembly: System (in System.dll)
. NET Framework Security:
WebPermission, which is used to access the requested URI or any URI to which the request was redirected. Associated enumeration: Connect.
Language
C#
C++
Jscript
Visual Basic
Show All
Provides public methods for sending data and receiving data from a resource identified by a URI to the resource identified by the URI. This class cannot be inherited.
For a list of all members of this type, see WebClient members.
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
Thread Safety
All public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. But there is no guarantee that any instance
Members are thread-safe.
Note
The WebClient class provides data that is sent to any local, Intranet, or Internet resource identified by the URI and receives data from those resources.
Public methods.
The WebClient class uses the WebRequest class to provide access to Internet resources. The WebClient instance can be passed through any
The WebRequest.RegisterPrefix method registers the WebRequest descendant to access the data.
Note by default, the. NET Framework supports URIs that begin with the http:, https: and file: Scenario identifiers.
The WebClient class provides four ways to upload data to a resource:
Openwrite returns a Stream that is used to send data to a resource.
Uploaddata sends a byte array to the resource and returns an array of bytes containing any responses.
UploadFile sends a local file to the resource and returns an array of bytes containing any responses.
UploadValues sends NameValueCollection to the resource and returns an array of bytes containing any responses.
The WebClient class also provides three ways to download data from a resource:
Downloaddata downloads data from the resource and returns a byte array.
DownloadFile downloads data from a resource to a local file.
OpenRead returns data from the resource as a Stream.
Requirements
Namespaces: System.Net
Platforms: Windows, Windows NT 4.0, Windows ME, Windows XP, Windows xp-based Home Edition, Windows XP
Professional, Windows Server 2003 series
Assembly: System (in System.dll)
. NET Framework Security:
WebPermission, which is used to access the requested URI or any URI to which the request was redirected. Associated enumeration: Connect.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service