HttpClientHandler.AllowAutoRedirect Propriedade
Definição
Obtém ou define um valor que indica se o manipulador deve seguir as respostas de redirecionamento.Gets or sets a value that indicates whether the handler should follow redirection responses.
public:
property bool AllowAutoRedirect { bool get(); void set(bool value); };
public bool AllowAutoRedirect { get; set; }
member this.AllowAutoRedirect : bool with get, set
Public Property AllowAutoRedirect As Boolean
Valor da propriedade
true Se o manipulador deve seguir as respostas de redirecionamento; caso contrário false .true if the handler should follow redirection responses; otherwise false. O valor padrão é true.The default value is true.
Comentários
Defina AllowAutoRedirect como true se você quiser que o manipulador siga automaticamente os cabeçalhos de redirecionamento de http para o novo local do recurso.Set AllowAutoRedirect to true if you want the handler to automatically follow HTTP redirection headers to the new location of the resource. O número máximo de redirecionamentos a seguir é definido pela MaxAutomaticRedirections propriedade.The maximum number of redirections to follow is set by the MaxAutomaticRedirections property.
Se AllowAutoRedirect é definido como false , todas as respostas HTTP com um código de status http de 300 para 399 são retornadas para o aplicativo.If AllowAutoRedirect is set to false, all HTTP responses with an HTTP status code from 300 to 399 are returned to the application.
O cabeçalho Authorization é limpo em redirecionamentos automáticos e o manipulador tenta automaticamente se autenticar novamente no local redirecionado.The Authorization header is cleared on auto-redirects and the handler automatically tries to re-authenticate to the redirected location. Na prática, isso significa que um aplicativo não pode colocar informações de autenticação personalizadas no cabeçalho de autorização se for possível encontrar o redirecionamento.In practice, this means that an application can't put custom authentication information into the Authorization header if it is possible to encounter redirection. Em vez disso, o aplicativo deve implementar e registrar um módulo de autenticação personalizada.Instead, the application must implement and register a custom authentication module.
Observação
Com AllowAutoRedirect definido como true , o .NET Framework seguirá redirecionamentos mesmo quando estiver sendo redirecionado para um URI http de um URI https.With AllowAutoRedirect set to true, the .NET Framework will follow redirections even when being redirected to an HTTP URI from an HTTPS URI.
As versões 1,0, 1,1 e 2,0 do .NET Core não seguirão um redirecionamento de HTTPS para HTTP, mesmo se AllowAutoRedirect estiver definido como true ..NET Core versions 1.0, 1.1 and 2.0 will not follow a redirection from HTTPS to HTTP even if AllowAutoRedirect is set to true.