tags:

views:

40

answers:

2

Hello,

i have a application thats writen with the pylons framework. Now i want to call some controllers from a vb.net application. How should i do this?

I've tried it like this:

Dim webclient As New WebClient
Dim dataStream As IO.Stream = webclient.OpenRead("http://192.168.0.20:5000/controller/default")
Dim reader As New StreamReader(dataStream)
Dim responseFromServer As String = reader.ReadToEnd()
Dim erg As String = responseFromServer.ToString
reader.Close()
dataStream.Close()

But instead of an json object that is generate by the pylons controller, i'll get the html code for the page which is reachable under "http://192.168.0.20:5000"

Any help would be great! Cheers, Nico

+1  A: 

You're probably requesting either the wrong content type or the wrong URL.

Make sure the URL is correct, or try this code:

Dim webclient As New WebClient

webclient.Headers.Add(HttpRequestHeader.ContentType, "test/json")
Dim erg As String = webclient.DownloadString("http://192.168.0.20:5000/controller/default")

As I demonstrated, you should use the DownloadString method instead of manually using a StreamReader.

SLaks
A: 

Thank you for the answer, but this brings me the same result.

I figured out that you have to first login to the page. That means i have to call another controller, which is responsible for the login. For that i have to add params in the post.

How i do this in vb.net?

Cheers Nico

Nico