×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Registered User
    Join Date
    Mar 2013
    Posts
    7

    Question httpwebrequest example windows phone 8

    hello

    I try to develop an app for wp8 to post data to website
    I want to use httpwebrequest
    any simple example can help me?

  2. #2
    Nokia Developer Expert
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,143

    Re: httpwebrequest example windows phone 8

    I would suggest that you try out your favorite search engine and type something like httpwebrequest example WP into the search box.

    Anyway, did that already, and here's one example to get you started:http://msdn.microsoft.com/en-us/library/hh221581.aspx

  3. #3
    Registered User
    Join Date
    Mar 2013
    Posts
    7

    Re: httpwebrequest example windows phone 8

    I'm try some of code and not work for wp8
    please by vb not c#

  4. #4
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,570

    Re: httpwebrequest example windows phone 8

    Searching for httpwebrequest example WP vb is also possible. It seems to find pages like http://stackoverflow.com/questions/1...vb-web-request

  5. #5
    Registered User
    Join Date
    Mar 2013
    Posts
    7

    Re: httpwebrequest example windows phone 8

    when I try to send data I get this error
    An unhandled exception of type 'System.UnauthorizedAccessException' occurred in System.Windows.ni.dll

  6. #6
    Nokia Developer Expert
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,143

    Re: httpwebrequest example windows phone 8

    Did you add any capabilities in your application manifest file when you added usage of the API ?

  7. #7
    Registered User
    Join Date
    Mar 2013
    Posts
    7

    Re: httpwebrequest example windows phone 8

    I add this capabilities

    ID_CAP_APPOINTMENTS
    ID_CAP_IDENTITY_DEVICE
    ID_CAP_IDENTITY_USER
    ID_CAP_NETWORKING
    ID_CAP_PROXIMITY
    ID_CAP_SENSORS
    ID_CAP_WEBBROWSERCOMPONENT
    ID_CAP_PUSH_NOTIFICATION

    this my code
    Private Sub Button_Click(sender As Object, e As RoutedEventArgs)
    If (txtbxn.Text = "" Or txtbxp.Text = "") Then
    MessageBox.Show("enter your user name and password!")
    Else
    Dim usrnm As Byte() = Encoding.UTF8.GetBytes(txtbxn.Text)
    Dim pso As Byte() = Encoding.UTF8.GetBytes(txtbxp.Text)
    Dim usrnms As String = System.Convert.ToBase64String(usrnm)
    Dim psos As String = System.Convert.ToBase64String(pso)
    Dim postData As String = "string" + vbCrLf + "string" + vbCrLf + "string" + usrnms + "string" + psos + "string"
    Dim hqst As HttpWebRequest = CType(HttpWebRequest.Create("http://www.example.com/example.php"), HttpWebRequest)
    hqst.Method = "POST"
    hqst.BeginGetRequestStream(New AsyncCallback(AddressOf GetRequestStreamCallback), hqst)
    End If
    End Sub

    Private Sub Button_Click_1(sender As Object, e As RoutedEventArgs)
    NavigationService.Navigate(New Uri("/MainPage.xaml", UriKind.Relative))
    NavigationService.RemoveBackEntry()
    End Sub

    Private Sub GetRequestStreamCallback(callbackResult As IAsyncResult)
    Try
    Dim hqst As HttpWebRequest = CType(callbackResult.AsyncState, HttpWebRequest)
    Dim pstrm As Stream = hqst.EndGetRequestStream(callbackResult)
    Dim bytd As Byte() = Encoding.UTF8.GetBytes("hello")
    pstrm.Write(bytd, 0, bytd.Length)
    pstrm.Close()
    hqst.BeginGetResponse(New AsyncCallback(AddressOf GetResponsetStreamCallback), hqst)
    Catch e As WebException
    End Try
    End Sub

    Private Sub GetResponsetStreamCallback(callbackResult As IAsyncResult)
    Try
    Dim hqst As HttpWebRequest = CType(callbackResult.AsyncState, HttpWebRequest)
    Dim hrsp As HttpWebResponse = CType(hqst.EndGetResponse(callbackResult), HttpWebResponse)
    Dim strmrdr As StreamReader = New StreamReader(hrsp.GetResponseStream())
    Dim rslt As String = strmrdr.ReadToEnd()
    MessageBox.Show(rslt)
    Catch e As WebException
    End Try
    End Sub
    please help me

  8. #8
    Registered User
    Join Date
    Mar 2013
    Posts
    7

    Re: httpwebrequest example windows phone 8

    I solve it !
    only remove the messagebox
    or use dispatcher to view the rslt

Similar Threads

  1. Windows Phone 8 HttpWebRequest.BeginGetResponse() issue
    By alih11 in forum Windows Phone General
    Replies: 3
    Last Post: 2013-07-12, 08:55
  2. Replies: 2
    Last Post: 2013-04-15, 12:10
  3. Windows phone 8 app installation on phone without putting it on windows store
    By KnowledgeSeeker in forum Windows Phone General
    Replies: 2
    Last Post: 2013-03-05, 12:12
  4. Replies: 1
    Last Post: 2013-02-14, 17:47
  5. Replies: 1
    Last Post: 2002-07-16, 06:44

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •