开发者

How to Post values from iPhone using ASIHttp?

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?


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:

NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@?name=%@&...",urlString,name,...];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];

on the client side.


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"]

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜