WelcomeServicesPortfolioKnowledge BaseContact Us
27 Seconds, Inc.


Knowledge base View Article

need hosting?

Need hosting? We use and love our host - CrystalTech.com!
Need hosting? We use and love our host - CrystalTech.com!

Text Disguise - CAPTCHA-image/Human Interactive Proof web services

National Holiday Dates and Bank Holiday Dates - web site that provides the dates of national and bank holidays for the United States, United Kingdom, Ireland and Scotland

Holiday Web Service - web services for programmers to provide the dates of national and bank holidays in their applications for the United States, United Kingdom, Ireland and Scotland

Our Family Heart - web site to help families communicate no matter where they are

What?! You haven't heard about the greatest remote controlled flyer to come out in years?! Checkout the FlyTech DragonFly now!

Make HTTP Requests from .NET Application

Summary: Make HTTP requests fron .NET applications quickly and easily using this shared/static function.
 
Keywords: GET
HTTP
POST
REQUEST
WEBCLIENT
Applicable Software: Active Server Pages .NET (ASP.NET)
Visual Basic .NET (VB.NET)
 
Body:

There are many occassions where you need to make HTTP calls from applications. The .NET framework has built-in support for doing this and this is a quick & simple class for doing that. Note, the routine is very slim on error handling (it just ignores them) - but the idea's there.

Public Shared Function GetHttpResponse(ByVal address As String) As String

	Dim wc As WebClient = New WebClient()
	Dim buffer As Byte()
	Dim response As String = ""
		
		Try
			buffer = wc.DownloadData(address)

			response = Encoding.ASCII.GetString(buffer)
		Catch x As Exception
			'do nothing
		End Try

		Return response

End Function

To use it, you would do:

Dim webpage As String = GetHttpResponse("http://www.27seconds.com/kb/article_view.aspx?id=59")

 
Author: Douglas L. Setzer, II, http://www.27seconds.com
Posted On: 12/21/2005 2:20:58 PM

Rate this article: Average: n/a
n/a12345678910
Comments?

Article Search   |   All Articles

 

 
©2002 27 Seconds, Inc. All Rights Reserved.