C# 如何使用ASIHttp从iPhone发布值?
我想将一些值从iPhone应用程序发送到服务器中的ASp.Net网页。我正在使用ASITP来实现这一点。它处理请求并调用服务器上的页面。但这些值都不是在服务器端检索到的。下面是来自iPhone应用程序的代码C# 如何使用ASIHttp从iPhone发布值?,c#,iphone,asp.net,objective-c,asihttprequest,C#,Iphone,Asp.net,Objective C,Asihttprequest,我想将一些值从iPhone应用程序发送到服务器中的ASp.Net网页。我正在使用ASITP来实现这一点。它处理请求并调用服务器上的页面。但这些值都不是在服务器端检索到的。下面是来自iPhone应用程序的代码 NSURL *url = [NSURL URLWithString:urlString]; ASIFormDataRequest *request = [[[ASIFormDataRequest alloc] initWithURL:url] autorelease]; [requ
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"]);
有人能帮忙吗?查询字符串用于URL中的值。帖子将在Request.Form或just Request中包含值,它们将通过QueryString&Form搜索这些值 另一个关于QueryString和Form的更详细的问题
我不认为
请求。QueryString[“name”]
将检索post参数。您需要更改ASIHttpRequest以将参数包含在查询字符串中,或者修改ASP.NET代码以使用post参数
您可以在服务器端尝试Request.Form[“name”]
,Request.Form[“phone”]
等
或者,您可以尝试:
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@?name=%@&...",urlString,name,...];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
在客户端。尝试从请求中注销响应。使用[请求响应数据];Request.QueryString用于检索GET参数。如果您在.NET中使用MVC,您可以简单地将方法注释为[HttpPost],并在方法签名中定义参数。