How does one configure HttpClient not to automatically redirect when it receives a 301 HTTP Status Code?

前端 未结 1 479
野性不改
野性不改 2020-11-27 06:00

Consider an ASP.NET Web API service that redirects

public class ThisController : ApiController
{
    /* more methods */

    public override HttpResponseMes         


        
相关标签:
1条回答
  • 2020-11-27 06:26

    Try:

    var handler = new HttpClientHandler() 
    {
        AllowAutoRedirect = false
    };
    
    HttpClient client = new HttpClient(handler);
    
    0 讨论(0)
提交回复
热议问题