如何使用 ASIHttp 从 iPhone 发布值?
我想将一些值从我的 iPhone 应用程序发送到服务器中的 ASp.Net 网页。我正在使用 asihttp 来实现这一点。它处理请求并调用服务器上的页面。但服务器端没有检索到任何值。以下是 iPhone 应用程序的代码。
NSURL *url = [NSURL URLWithString:urlString];
ASIFormDataRequest *request = [[[ASIFormDataRequest alloc] initWithURL:url] autorelease];
[request setPostValue:@"abc" forKey:@"from"];
[request setPostValue:@"abc" forKey:@"name"];
[request setPostValue:@"abc" forKey:@"phone"];
[request setDelegate:self];
[request startSynchronous];
在服务器端,我使用 asp.net c#。这是用于检索值的代码。但我得到的是空字符串?
sendMail(Request.QueryString["name"],Request.QueryString["from"],Request.QueryString["phone"]);
有人可以帮忙吗?
I want to send some values from my iPhone application to an ASp.Net web page in server. I am using asihttp for that. Its processing the request and invoking the page on server. But the none of the values are retrieved in server side. Below is the code from iPhone app.
NSURL *url = [NSURL URLWithString:urlString];
ASIFormDataRequest *request = [[[ASIFormDataRequest alloc] initWithURL:url] autorelease];
[request setPostValue:@"abc" forKey:@"from"];
[request setPostValue:@"abc" forKey:@"name"];
[request setPostValue:@"abc" forKey:@"phone"];
[request setDelegate:self];
[request startSynchronous];
On Server side I am using asp.net c#. THis is the code using for retriving values. But I am getting emtpy string?
sendMail(Request.QueryString["name"],Request.QueryString["from"],Request.QueryString["phone"]);
Could Someone help Please?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为
Request.QueryString["name"]
不会检索 post 参数。您需要更改 ASIHttpRequest 以在查询字符串中包含参数,或者修改 ASP.NET 代码以期望发布参数。您可以在服务器端尝试
Request.Form["name"]
、Request.Form["phone"]
等。或者,您可以尝试:
在客户端。
I don't think
Request.QueryString["name"]
will retrieve a post parameter. You either need to change your ASIHttpRequest to include the parameters in the query string, or modify your ASP.NET code to expect post parameters.You could try
Request.Form["name"]
,Request.Form["phone"]
, etc. on the server side.Or, you could try:
on the client side.
QueryString 用于 URL 中的值。帖子将在 Request.Form 中包含值或仅在 Request 中包含值,该值将通过 QueryString 和 QueryString 进行搜索。值的形式。
另一个问题更详细地介绍了 QueryString 与 Form。
Request["key"] 与 Request.Params[" key"] 与 Request.QueryString["key"]
QueryString is for values in the URL. A post will have values in Request.Form or just Request which will search through QueryString & Form for the values.
Another question with more detail about QueryString vs Form.
Request["key"] vs Request.Params["key"] vs Request.QueryString["key"]