On SharePoint 2010 i have many wikipages containing a table. Is it possible to view the content of that page in vb.net using the client object model?

I tried to get the file code using a stream but the text i get is a lot of asp.net code (with the placeholders) but not the html code/content from that page...

    Dim fileAlgemeen As SP.File = Nothing
    Dim siteUrl As String = "https://portal.xx.be/sites/kdb"
    Dim ctx As New ClientContext(siteUrl)
    Dim credentials As NetworkCredential = New NetworkCredential("xx", "xx")
    ctx.Credentials = credentials
    Dim web As Web = ctx.Web
    Dim relativeUrl As String = "/sites/kdb/596/Algemeen.aspx"
    Dim file As SP.File = web.GetFileByServerRelativeUrl(relativeUrl)

    Dim fileRef = relativeUrl 

    Dim fileInfo As FileInformation = SP.File.OpenBinaryDirect(ctx, fileRef.ToString())

    Using fileInfo.Stream
        Using sr As StreamReader = New StreamReader(fileInfo.Stream)
            Dim line As String = sr.ReadToEnd()
            lbl.Text = line
        End Using
    End Using

The following example demonstrates how to read and update wiki content using SharePoint CSOM (VB.NET)

Sub Main()

    Const siteUrl As String = "https://contoso.sharepoint.com/kb/"
    Const userName As String = "username@contoso.onmicrosoft.com"
    Const password As String = "password"

    Using ctx = New ClientContext(siteUrl)

        Dim credentials As NetworkCredential = New NetworkCredential(userName, password)
        ctx.Credentials = credentials

        '1. Read Wiki content 
        Dim wikiFile = ctx.Web.GetFileByServerRelativeUrl("/kb/Pages/Welcome.aspx")
        Dim wikiItem = wikiFile.ListItemAllFields

        '2. Update wiki content
        wikiItem("PublishingPageContent") = "<h1>Welcome to the SharePoint!</h1>"

    End Using

End Sub

Key Points:

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.