发送数据Unsing HTTP请求C# [英] Send data Unsing HTTP Request C#

查看:127
本文介绍了发送数据Unsing HTTP请求C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用HTTP请求将数据发送到远程服务器(本地主机)的形式.是否可以以及如何使用C#发送数据并使用PHP接收数据?
请指导我!

I want to send data using HTTP request to a form of a remote server(localhost). Is it possible and how to send data using C# and Receive that data using PHP?.
Please guide me!

推荐答案

http://blog.brezovsky.net/ [ ^ ]

Google [ ^ ]了解更多...
http://stackoverflow.com/questions/304337/post-data-to-a-php-page-from-c-winform[^]
http://blog.brezovsky.net/[^]

Google[^] for more...


您不向表单发送HTTP请求.这是客户端上的一个表单,将HTTP请求发送到服务器.表单本身是在服务器上创建的事实并不重要-在您请求该页面时,您是根据您的上一个请求收到的.

现在,HTTP请求既是HTTP请求,又是响应-如果服务器端的内容无关紧要,则可以使用:PHP,ASP.NET或其他任何东西.您甚至无法从客户端确定这一点.

要在HTTP请求中发送数据,您需要从.NET程序中将类System.Net.HttpWebRequestMethod"POST"一起使用.您将需要发送与表单相同的数据.要查看应发送哪些数据,请查看表单的HTML代码.请求变量的编译时类型将是类System.Net.WebRequest,因为请求的运行时类型将通过其工厂方法Create根据您的URL进行定义.

您将在这里找到代码示例: http://msdn.microsoft.com/zh-我们/library/system.net.webrequest.aspx [ ^ ].

—SA
You do not send HTTP request to a form. This is a form on client sends HTTP request to the server. The fact that the form itself was created on server does not matter — you received it in response to your previous request, when you requested for the page.

Now, HTTP request is HTTP request, as well as response — if does not matter what''s on the server side: PHP, ASP.NET or anything else. You cannot even determine that from your client side.

To send your data in HTTP request you need from .NET program to use the class System.Net.HttpWebRequest with the Method "POST". You will need to send the same data a form would. To see what data should be sent, look at the HTML code of the form. Compile time type of the request variable will be the class System.Net.WebRequest, as the request''s run-time type will be defined based on your URL by its factory method Create.

You will find the code sample here: http://msdn.microsoft.com/en-us/library/system.net.webrequest.aspx[^].

—SA


这篇关于发送数据Unsing HTTP请求C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆