简体   繁体   中英

401 Unauthorized only when on server

Problem: This code works fine from my local machine, but NOT on the server itself. (EG I can run this Linqpad script from my machine, I get a 200 and some data. I copy it to the server where the app is hosted and I get a 401. Why!? App has Windows Auth only enabled, NTLM only.

//Create REST client
var client = new RestClient("https://app.com/service/")
                {
                    //Windows Auth
                    Authenticator = new NtlmAuthenticator("test\\test", "9#@903f")
                };

//Create Request to be sent             
var request = new RestRequest("api/dogs/furriest");

//Create params to send
var parameters = new        {
    FurryLevel = 1,
    CuteLevel = 2
};

//Add params to request
request.AddParameter("application/json", parameters.ToJson(), ParameterType.RequestBody);

//Execute the request
var response = client.ExecuteAsPost(request, "POST");

您是否在IIS站点上启用Windows身份验证?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM