Sunday, March 18, 2012

HTML Head Title Access Denied

The great helpful thing about developing with .NET is, a lot of objects introduced in .Net framework.One of them is this web client object. Earlier days we need to send the XmlHttp request or Web Request to send the request and receive the response. WebClient not only reduced the effort in downloading text, but also helpful in a lot of areas such as security and form submission etc…

As I said before the download string function makes the life easier. You can simply pass the URL to this function and it will return the response text. If the resource is secured you can send the Network Credentials to authenticate,
Dim webClient As New WebClient()
Dim Downloaded= webClient. DownloadString(URI)

Now that is the error we are receiving, means that the access is denied while calling the resource. So we need to authenticate. Use the following to authenticate. The Response can be received using DownloadStringAsync(Uri, Object) method Asynchronously as well
webClient.Credentials = New NetworkCredential(username, password)


View the original article here

No comments:

Post a Comment