Tuesday, February 09, 2010

Accessing Webservice by using Sys.Net.WebRequest

Let us understand what is Sys.Net.WebRequest. WebRequest is the abstract base class for the .NET Framework's request/response model for accessing data from the Internet. An application that uses the request/response model can request data from the Internet in a protocol-agnostic manner, in which the application works with instances of the WebRequest class while protocol-specific descendant classes carry out the details of the request.

Requests are sent from an application to a particular URI, such as a Web page on a server. The URI determines the proper descendant class to create from a list of WebRequest descendants registered for the application. WebRequest descendants are typically registered to handle a specific protocol, such as HTTP or FTP, but can be registered to handle a request to a specific server or path on a server.

WebRequest Class throws an exception when error occurs. The Status is the property of WebExceptionStatus.

Lets start building our application.

Step 1:

Open Visual Studio > New Website> give the name as WebRequestApp> programming language as C#.

Read more: .NET Funda

Posted via email from jasper22's posterous