in Backend Tech

WebClinet class in asp.net

I didn’t know WebClient class that much until today.
I did some experiments with that class and found it very useful when you need to update content that Livelink maintains.
Livelink has a public fetch feature, which is a link to get a document stored in Livelink. An user types livelink the public fetch url in the address bar on the browser and gets to see the document on browser if the document is html type.

Anyways, so Livelink is my content respository. All I need to do in order to see the content is to set up an asp.net page and have it read and set Text property of Label or TextBox to whatever is in the document in Livelink.

The minimal coding for the solution was (I’m using Visual Studio 2003 and VB.net):

Imports System
Imports System.Net
Imports System.IO

Public Class htmlcontentProxy
Inherits System.Web.UI.Page

#Region ” Web Form Designer Generated Code ”

‘This call is required by the Web Form Designer.
Private Sub InitializeComponent()

End Sub
Protected WithEvents lb_result As System.Web.UI.WebControls.Label

‘NOTE: The following placeholder declaration is required by the Web Form Designer.
‘Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
‘CODEGEN: This method call is required by the Web Form Designer
‘Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
‘Put user code to initialize the page here
Dim InsightURL As String = “http://livelink/llfetch/livelink.exe?func=pfpublic.fetch&nodeid=34811580”
Dim client As New WebClient
Dim data As Stream = client.OpenRead(InsightURL)
Dim reader As New StreamReader(data)
Dim s As String = reader.ReadToEnd()
lb_result.Text = s
End Sub

End Class

Very simple and useful. As long as a document in Livelink is a html formatted text file, this should work without any issues.