Thief program (ASP.NET + C #)

xiaoxiao2021-03-30  228

Create an ASP.NET program under the .NET platform.

1, reference two Namespace

Using system.text // Because of the Encoding class

Using system.net // Because of the WebClient class

2, three controls for the entire program

TXTURL / / Enter the web address TEXTBOX control you want to get

TXTBODY / / Get the web content you have to get TextBox control

btnreturn // Button Button Control

3, code under ***. Aspx.cs

Private void btnreturn_click (Object Sender, System.EventArgs E)

{

String url = txturl.text.trim (); // Get the input web address

WebClient WB = new WebClient (); // Create a WebClient instance

// Get or set the network credentials for authenticating the request to the Internet resource. (No available)

//wb.credentials=credentialcache.defaultcredentials;

// Download data from the resource and return to the byte array. (@ 是 because there is "/" symbol in the middle of the URL)

Byte [] pagedata = wb.downloaddata (@url);

// Convert characters,

String result = encoding.default.getstring (pagedata);

TXTBODY.TEXT = Result;

}

4, word ***. Add a code in the HTML code of ASPX

Add ValidateRequest = False in the first line of code <% @ Page = ...........................%>

Summary: The whole code is only a few lines, but also don't have to worry about it. I am in the help document, in fact, the WebClient class has a lot of ways to download resources and upload resources, interested friends can look at the following Help documents for WebClient classes:

WebClient class, please see

WebClient Member | System.Net Namespace | WebRequest | WebResponse | HTTPWEBREQUEST |

HTTPWebResponse | WebClient Members (Visual J # Syntax) | C Hosting Extension Programming

Claim

Name Space: System.net

Platform: Windows 98, Windows NT 4.0, Windows ME, Windows 2000, Windows XP Home Edition, Windows XP

Professional, Windows Server 2003 Series

AGM: System.dll in System.dll

.NET Framework security:

WebPermission, any URI for accessing the requested URI or requests to be redirected. Associated enumeration: Connect.

Language

C #

C

JScript

Visual Basic

All display

Provides a public method for transmitting data to the URI identified resource and the resource received from the URI. This class cannot be inherited.

See WebClient members for a list of all members of this type.

System.Object

System.MarshalByrefObject

System.componentmodel.component

System.Net.WebClient

[Visual Basic]

Notinheritable Public Class WebClientinherits Component

[C #]

[ComVisible]

Public Sealed Class WebClient: Component

[C ]

[ComVisible]

PUBLIC __GC __SEALED CLASS WebClient: Public Component

[Jscript]

public

Comvisible (TRUE)

Class WebClient Extends Component

Thread security

All public static (Visual Basic) members are safe for multithreading operations. But does not guarantee any instance

Members are thread safety.

Note

The WebClient class provides any local, intranet, or Internet resource that is identified to the URI, and receives data from these resources.

Public method.

The WebClient class uses the WebRequest class to provide access to the Internet resource. WebClient instance can pass any

WebRequest.RegisterPRefix method registered WebRequest submitted access data.

Note By default, .NET Framework supports the URI that starts with http:, https:, and file: scheme identifier.

The WebClient class provides four ways to load data to resources:

OpenWrite returns a stream for sending data to the resource.

UPLoadData sends the byte array to the resource and returns an array containing any response.

UploadFile Sends a local file to the resource and returns an array containing any response.

UploadValues ​​sends NameValueCollection to the resource and returns an array containing any response.

The WebClient class also provides three ways to download data from the resource:

Downloaddata downloads data from the resource and returns the byte array.

Downloadfile downloads the data to a local file from the resource.

OpenRead returns data from the resource in Stream.

Claim

Name Space: System.net

Platform: Windows 98, Windows NT 4.0, Windows ME, Windows 2000, Windows XP Home Edition, Windows XP

Professional, Windows Server 2003 Series

AGM: System.dll in System.dll

.NET Framework security:

WebPermission, any URI for accessing the requested URI or requests to be redirected. Associated enumeration: Connect.

转载请注明原文地址:https://www.9cbs.com/read-130574.html

New Post(0)