Simple POST request to PHP from Windows Phone 7 - c#

I am new to developing Windows Phone applications using C# and I am trying to send some data through POST to a PHP file from my Windows Phone 7 application on click of a button. I wish to receive the reply from the PHP script and print it out to a Text Block. I have tried some code samples from MSDN, but they throw some errors which I am not able to understand.
This was the sample from MSDN that I tried : http://msdn.microsoft.com/en-us/library/ktfa4fek%28v=VS.90%29.aspx
I ran into many errors by trying the above example. Can anyone help me with the C# code to send POST data to PHP and receive response from it? Also, to get the response, is it enough to Echo the data from PHP or do I need to do something else like returning the value?

The problem is you are trying to use an example from the full .NET Framework. Windows Phone 7 does not support the full .NET framework. Your app actually has to target the Silverlight Framework, and if you look at the WebClient class in Silverlight, there is no UploadData() method.
You have to use one of the appropriate methods in WebClient for Silverlight
Without knowing more of your code and what you are trying to upload, it is hard to say which one, but you have several overloads of UploadStringASync() or OpenWriteASync() to choose from.
Likewise the other classes you are trying to use do not have the methods in the Silverlight framework

Related

How to use asymmetric encryption between my console & wpf app?

I am stuck when it comes to keep data save over web, I have a console application that acts as my host portal (using owin selfhost) to handle requests and I have a WPF application that my users can use at any time, this WPF application is suppose to ask for information like my connection string info to connect to the database, since i did not want to put that information hardcoded in the application (for decompile reasons) I decide to let the WPF application make a request over web (using WebClient) to receive the database connection string information, but since we cant just send that back as plain text, we do need encryption and there is where I am stuck.
I use a class library to store the encryption methods (encrypt/decrypt) and implement that library in both applications, when a request comes in my console application is encrypting the data to send it back to the WPF application but my WPF application cannot decrypt the data, there is where I am running into exceptions thus the data stays encrypted and is basicly useless at this moment.
Can somebody please explain me how to fix this problem so any user can make requests with the WPF application to my console application while everything been send over the web is encrypted and safe?
I am fairly new when it comes to this topic, and when I look around on the internet I only get examples where encryption and decryption is done in the same application with build in classes inside the application itself rather then using libraries to share it across multiple applications within the same solution. So far nothing really helped me, i have been looking for 2 days for this now, watched a ton of youtube videos but they all end up the same using it in the same application...
If i do that aswell, it works fine, but once I try with my WPF application the data fails to decrypt.
I hope somebody can lead me to a solution with this.
My appologies if my english is a bit broken, I am trying my best to improve this.
If you need more information to understand my problem please ask, I provide as much info as I can

what is the best way to transfer data between android application and WPF desktop application over network

I 'm working on system that consisted of two part .first part is android application (client app) capture image and send to WPF application .second part is WPF application (server application) that receive that image , do some kind of processing on it and send back info about the image ,so what is the best way to make it work like server(WPF)/client(android) .
Using HTTP, preferably implementing as REST service, is the way to go. WPF/WCF and Android have libraries you can use to implement this. For Android, take a look at [Android's HTTP clients][http://android-developers.blogspot.com/2011/09/androids-http-clients.html) blog post.
Thanks ,I search about it and i found this framework Eneter and this Example on it Android: How to communicate with .NET application via TCP .

How to Retrieve (Get) Response Headers (Accept-Language) Without Using the Internet?

I was hoping to get the "Accept-Language" header that a users Internet Explorer browser sends to web pages (servers). I wanted to do this without connecting to a web page, but just through some .dll COM call or Windows API or some other method that would give me this information without connecting to the internet. I'l looking for the most reliable method which spans Window 2000 - Windows 8.1.
I am open to getting this by making a web request but would prefer to do it without, ie: by making an API call or doing it the real way (whatever that is). When I searched the internet/google, people would only show code examples that involve connecting to some server etc... and I couldn't find the local (non-internet) method of doing this.
Anyone know? I am using VB6 (Visual Basic 6.0) but can take code examples in VB.NET or C# as they are easy to translate for me.
Accept language is stored in registry(Help: How to change the default language for Internet Explorer using C# code?):
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\International
REG_SZ: AcceptLanguage
example en-gb,ar-eg;q=0.5
In vb.net it is simple( How to: Read a Value from a Registry Key in Visual Basic)
Dim readValue = My.Computer.Registry.GetValue("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\International",
"AcceptLanguage",Nothing)
In vb6 is necessary to use API see: Microsoft:How To Use the Registry API to Save and Retrieve Setting

sound recording using Naudio .Net class library in web application

is it possible to record sound using Naudio (https://naudio.codeplex.com/) .net class library in C# web application ??
I have requirement to record sound (of users) in web application.
Please let me know.
Thanks
It is not possible - c# is backend (works on server) application, while your website is frontend (works on client's machine). Any ties between those two are cut after server sends rendered page to client.
The best you can get - do a recording using some sort of javascript library (though I am not sure, that those exist), and send the recorded file to server via AJAX or simple POST as a form's file element.
Oh, you could use flash/silverlight or something like that as well. Might be even easier.

Windows phone application

Just started to look on how to develop on windows phone and i found about PhoneGap and Visual WebGui and i thought about the next ideea: if i start a new silverlight for windows phone application in visual studio and i create a web browser, like i saw in PhoneGap, and to use javascript and html5 for the application. The problem is that i want to use Sockets from C# (since javascript only has websockets... ), i know i can use java script code in C# to manipulat a html5 page but is it possible if the user clicks a button to use the Socket from C# to send a message to the server(like using javascript to call a method written in C#)?
Thanks
Yes, you can create your own FFI between JS & C# to create a bridge in both directions. The PhoneGap code should provide a good example of how to call in both directions.

Categories

Resources