I want ot pass username and password in URL(web service) for user authentication which will return true and false.I'm doing this as following:
NSString *userName = [NSString stringWithFormat:@"parameterUser=%@",txtUserName];
NSString *passWord = [NSString stringWithFormat:@"parameterPass=%@",txtPassword];
NSData *getUserData = [userName dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *getUserLength = [NSString stringWithFormat:@"%d",[getUserData length]];
NSData *getPassData = [passWord dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *getPassLength = [NSString stringWithFormat:@"%d",[getPassData length]];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc]init];
[request setURL:[NSURL URLWithString:@"http://URL/service1.asmx"]];
[request setHTTPMethod:@"GET"];
Now, I wanted to know How can I pass my username and password in this URL to make request. Could any one please suggest or give some sample code? Thanks.
Try this :-
Hope it helps you..
First off I would not pass a username and password across in a url. You should do this using post.
This is more secure then passing sensitive data across in a url.
Edit
To get the response you can check this out. NSURLConnection and AppleDoc NSURLConnection
You can use a few different methods to handle the response from the server. You can use
NSURLConnectionDelegate
along with the delegate call backs:
Or you can also use
NSURLConnection sendAsynchronousRequest
blockTo improve the secure , you may use the Http Basic Authentication. There are answer here.