Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios NSURLConnection身份验证挑战,即使它不应该_Ios_Http_Authentication_Nsurlconnection - Fatal编程技术网

Ios NSURLConnection身份验证挑战,即使它不应该

Ios NSURLConnection身份验证挑战,即使它不应该,ios,http,authentication,nsurlconnection,Ios,Http,Authentication,Nsurlconnection,我可以使用NSURL进行身份验证,用户可以分配用户名和密码。然而,我有另一个问题。如果我打开它,它也会弹出并询问用户名和密码。我得到了认证,即使它不应该得到。我想知道怎么做 -(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType { if(!_auth) {

我可以使用NSURL进行身份验证,用户可以分配用户名和密码。然而,我有另一个问题。如果我打开它,它也会弹出并询问用户名和密码。我得到了认证,即使它不应该得到。我想知道怎么做

-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
   if(!_auth)
    {
   connection_for_auto = [[NSURLConnection alloc] initWithRequest:request delegate:self];
          firsttimeonly=TRUE;
         [connection_for_auto start];
        NSLog(@"Request >>  %@ and !firsttimeonly",request);
        return NO;
    }
    self.lbl_error.hidden = YES; //hide error message label
    return YES;

}

- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
{

    checkTochangeUIalert=TRUE;
    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Login"
                                                    message:nil
                                                   delegate:self
                                          cancelButtonTitle:@"Cancel"
                                          otherButtonTitles:@"OK",@"Auto", nil];

    alertView.transform=CGAffineTransformMakeScale(1.0, 0.75);
    alertView.alertViewStyle = UIAlertViewStyleLoginAndPasswordInput;
    [alertView show];
}

我想我已经找到了一个方法。我需要检查我使用什么样的身份验证方法

if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodHTTPBasic] || [challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodNTLM])
{
.............
}